The appearance of mandrake root in Harry Potter is most peoples' first introduction to the legendary root. Its humanoid appearance and shrill, damaging scream in the books and movies aren't the invention of author J. K. Rowling, however - they're echoes of a longstanding tradition, which holds that mandrake root is a powerful magical substance with an uncanny resemblance to humans. Mandrake root witchery goes back centuries, with its medicinal use originating in ancient Greece.
Popular culture's use of the mandrake root myth plays with superstition and facts in equal measure. While it's easily demonstrated that mandrake root doesn't really scream and cause death, that doesn't mean it's safe. In fact, it's a dangerous plant - its use in medicine and witchcraft arose from centuries of study, testing, and, naturally, misuse and accidents along the way.
The only feature of the mandrake more famous than its humanlike shape is its tell-tale scream. According to popular legend, the plant - or, depending on how you look at it, the creature - has a deadly, piercing scream. The sound is said to cause death or illness to those who hear it, leading those who want to harvest it to develop complex methods to unearth it from the ground without being harmed themselves. Some believe these stories were deliberately invented by witches of the past to warn people away from the herb, which was both dangerous if used improperly and a precious commodity for magical and medical professionals throughout history.
Because mandrake root was said to have a harmful scream, people who wanted to harvest it had to come up with creative solutions to avoid getting hurt. Rumors varied as to whether the mandrake's scream would kill you or merely damn you to hell, but people responded by stuffing their ears full of wax before harvesting the root. In actuality, this process doesn't do anything at all - mandrake doesn't scream, deadly or not. Though the root is dangerous due to poisons, which can affect people who touch it, stuffing ears full of wax isn't going to help.
All the elaborate methods of harvesting mandrake root had to be for something - that's a lot of effort to put in to anything. In fact, the root was said to be a potent magical substance, especially because of its looks. People believed that the root could be used in love potions or love spells in a variety of forms. Though the plant shouldn't be consumed - the root in particular is quite poisonous, as it's part of the nightshade family - magical advice throughout history has advocated for people carrying around roots that look like their preferred partner's gender to attract love. Of course, this encouraged people to carve up roots, some of which weren't even mandrake, to make them look more or less masculine or feminine to sell them to gullible customers. Whether or not the spell works at all is hard to prove, but a counterfeit root certainly won't do the trick.
Love wasn't the only thing mandrake was said to be good for. It was also seen as a general good luck charm, whether the root was just carried or worked into some kind of charm or potion. According to Jean-Baptiste Pitois' The History and Practice of Magic, the ritual to make the mandrake into a powerful object involved burying it at night in a grave, then watering it with cow's milk that had been used to drown bats. The plant grew so popular as a good luck charm that wily entrepreneurs started substituting mandrake with bryony, a similar-looking plant. Though bryony was also sometimes said to have magical properties - Jean-Baptiste Pitois claimed as much - it's hard to say whether that belief came about because of the English mandrake's small size and scarcity or whether the magical properties were considered to be there all along.