Long before the concept of "designer babies" created in a lab became the stuff of science fiction, inbreeding in royal families was viewed as a way to ensure genetic purity. Intermarriage ensured that no "common" blood sullied pure, aristocratic bloodlines. Inbred royalty - what could go wrong?
A lot, actually. Birth defects caused by inbreeding were rampant in royal families from Russia to Portugal and even in ancient Egypt, where the practice of sibling marriage was considered godly behavior. Royal family hereditary diseases and deformities caused by inbreeding - such as porphyria, among others - get handed down through thin gene pools, particularly in the many cases where intentional close marriage is used to ensure that royal blood (and its recurrent flaws) are kept in the family. For example, Queen Victoria, a major proponent of pure bloodlines, married her cousin Albert, and the two had nine children who then passed hemophilia to royal families throughout Europe.
While all these families hoped close intermarriage would keep their royal families stronger, in many cases, illness, madness, infertility and deformities caused by inbreeding ended up tearing them apart.
The mentally unstable Queen Maria I was married to her uncle. Known as the Mad Queen, she was given to delusional fits and religious obsessions. Maria spent much time in seclusion, but her howling could be heard throughout the royal estate.
Her grip on sanity was so feeble that by 1799, her son John was the unofficial ruler while she remained queen in title only. Eventually, the family fled to Brazil during the Napoleonic Wars, and Maria I passed in a convent.
Joanna of Castile was the older sister of Catherine of Castile, the poorly treated first wife of Henry VIII. Joanna wasn't originally intended to inherit the thrones of Castile and Aragon (the kingdoms that would be combined to create the nexus of the Spanish Empire), but when she outlived a number of siblings, she ended up wearing the crown. This wouldn't have been a big issue had she been a competent and capable ruler, as her mother had set an unusual precedent for strong Spanish queens, but her mental state was slightly impaired, to say the least.
When she married her Habsburg husband, remembered to history as Philip the Handsome, she fell desperately and completely in love with him. Unfortunately, their love story wasn't a happy one and he cheated on her multiple times before passing at an early age, leaving her a bereaved widow. Well, she was a little more than bereaved and supposedly lost her sanity to such a degree that she was removed from power and spent the rest of her days crying over her husband's remains. Yes, she held onto it.
Her ancestors, members of the extinct royal House of Trastámara, had been marrying members of their own family for generations, and it's incredibly likely this trend was a leading cause of Joanna's mental instability.
Like his cousin, the Empress of Austria, King Ludwig II of Bavaria was a member of the old Wittelsbach dynasty. The family had been intermarrying for generations, and the effects of such close consanguinity were leaving their marks upon the family members. Ludwig was known for being absolutely out of touch with reality and preferred to live in a self-made fantasy, which would have been fine had he not been a king with a job to do. While he went about building castles and sailing in swan-shaped boats, the Bavarian government was tearing their hair out over the inadequacies and wastefulness of their king.
Ludwig was eventually deposed, but not happily - the day after he was removed from the throne, his body was found by a lake, clearly the victim of foul play.
Queen Victoria, known as the matriarch of European royalty, had hemophilia, a blood-clotting disorder. Though she managed to avoid most serious side effects of the disease throughout her lengthy lifetime, the ancestors who brought it with them to royal houses throughout Europe were not so fortunate. Typically, hemophilia is acquired by women through both parents' genes and would have had nothing to do with the fact that Queen Victoria was married to her first cousin, Prince Albert.
However, historians have disputed whether or not the queen's father - Edward, the Duke of Kent - was, in fact, her biological one.