How has this peculiarity survived into the present day? In a democratic country where we elect our leaders what is the purpose of the monarchy? This may come across as a loaded question but it's not, I'm just curious.
Monarchies are hardly peculiar in Europe. Norway, Sweden, Denmark, Spain, the Netherlands, Belgium, Luxembourg are all monarchies. Former socialist republics in Central and Eastern Europe are not, but republics aren't even an overwhelming majority in Western Europe. Interestingly (and perhaps surprisingly), some of these monarchies have been (re)established as independent kingdoms quite recently – the Netherlands (1806-15), Belgium (1830-31), Norway (1905), Spain (1975-78) – and are by no means simply the remnants of some continually existing medieval kingdoms.
They are also a diverse bunch, with somewhat different constitutions, although not necessarily all that different from those of parliamentary democracies with weak presidents like Germany or Greece. In a way, France and Switzerland, both republics and very different from each other, are the most peculiar among larger European states and what's most peculiar about the UK is, among other things, first-past-the-post voting and the associated party system, not so much having a queen.
In some European countries, the ruling family was ousted quite forcefully and the republican system came to be associated with freedom and modernity (e.g. France, Portugal or Italy, where members of the former royal family were banned from entering the country until very recently). In some cases (e.g. Greece, Germany or Italy), the monarchy has also been tainted by its association with fascist or authoritarian rule. In fact, France came very close to a second restoration of the monarchy in the 1870s, which failed in part because the prospective king would accept nothing else than absolute power. There is a lot more to it of course, starting with the vagaries of each country's history but based on these examples, it might perhaps be said that monarchies exist today in countries where they knew to reform themselves and weren't too strongly associated with authoritarian rule.
It's because every advantage has its disadvantage.
You look up "monarchy" and you see currently Europe has constitutional monarchies (Liechtenstein, Monaco lead by princes; Luxembourg an archduke), where the Head of State has to be politically neutral and has to sign every democratic decision into law (Belgium's previous king got abdicated temporarily so as not to not personally sign abortion into law, thus respecting both democracy and his personal morals). These used to be absolute monarchies, where the monarch really ruled the country.
This is no different from republics, where the options range from say Italy and Germany with ceremonial presidents (I had no idea of the current nor previous German one, where just about everybody can name Merkel as the current chancellor; in Italy I came up with Napoletano as previous) to on the other hand obviously the a single person able to change the direction of the entire country, whether by democratic design (USA) or autocratic ("banana republics", Central Asia, ...); and a whole spectrum inbetween from weak to strong powers (say France, Russia).
So your question mostly covers constitutional monarchies (the current European reality) versus a very wide range of presidencies. You'll have to figure out why some countries want strong heads-of-government (Italy, Germany) instead of strong heads-of-state (USA, Russia) in another question. So I'd consider just a rephrased Why are some ceremonial heads-of-state presidents and others monarchs?.
So, why do you still have monarchies? Inertia is a big factor of course, "tradition", "stability". But also because it works on many levels.
Running a ceremonial presidency or constitutional monarchy costs roughly the same. Royalty will typically have more (ludicrously expensive, historical) properties to upkeep (with the UK prime example) than a presidency, and more family members (needing public protection) to fill them, but they are typically rich families anyway, and have a moral leadership tradition so they will all be working: Very few will get personal cash payment, and the infrastructure cost is just the nation's decision of how many it wants to support (compare the ludicrous costs at the moment to restore Westminster's not-even-that-old Big Ben/Victoria tower; the nation wants to spend that on its image/patrimony, whether royal or parliamentary palace). Inevitably, compare with Trump having more properties than many royal families, and posing an unprecedented cost for ensuring his safety at all those places (from a security standpoint, it's like setting up a White House on the run in every place; traditionally it's just the White House and Camp David, plus a personal place like the Bush family ranch which is easily defended).
Royals are mostly politically neutral. Consider the Spanish king who basically saved democracy by embodying "the people" in the face of a military coup: The coup wants to restore the military dictatorship just-abandoned, so a lot of the right-wing base and leadership have mixed feelings, while the left wing seem to be trying to save their personal power; as a neutral face for "all the country" he focused public opinion. So the Dutch monarchy is famously down-to-earth, with some of the recent past queens very much on a level with "the man in the street"; others are more intrinsically upper class (Belgium, UK). But unlike a former politician voted at the end of their career into presidency, they've never crafted nor supported any specific policy, they've never opposed "your" party. Compare the Dutch queen visiting the devastation of the 1953 floods to Trump visiting Houston: To many he's "No My President" (like Hillary wouldn't be to others); I'd hazard that many Las Vegas victims would refuse him at their bed, especially as he's veered to pro-NRA on apparently just stategic motives. A Republican president visiting a poor ward in New Orleans has more trouble relating than a Prince Harry in an English council estate. They're consensus figures.
Royals are groomed for the job, lifelong. They have the decorum (yea, Trump), they "look the part". They don't expect any power, don't have an agenda to push through. Hence their presidential equivalent, the unobtrusive career politician. Where they break decorum/"the mould", it's mostly spouses-not-raised-for-this (UK: Diana and Philip; though the fact he's a century old and hasn't moved with the times is part of that).
They have international standing. This is the main advantage. UK and Germany are similar size, but at a gathering any freshly elected head-of-state will be pick out William, Harry, ElisabethII, Philip, Charles and whats-her-face, but they'll simply wander past Steinmeier talking to Mattarella.
So you can reverse the question, most points being similar/equal/to-be-shaped-by-specific law, why are there so many ceremonial presidents instead of all monarchies? That is because the monarchy wasn't constitutional at a point of upheaval (France!), so once destroyed a monarchy isn't easily re-founded (France tried a bit); or beginning from nothing you don't have royalty (USA; South America; Ex-colonies in Africa and Asia; ... ).
[And beyond the simple republic-vs.-monarchy you have various "republic in name only?" countries, like the "Democratic" Republic Congo (DRC) and central-Asia where a strongman (Kabila) takes power, is "president", but is succeeded by a relative (son, nephew) without election. Just like India and the USA sustaining political dynasties (Bush, Clinton, Gandhi, ...), they're still voted in so an unbroken line of one family wouldn't make it less of a democracy.]