Just as the garlic has been thought to ward off vampires or other evil spirits, it is also found in the mythology of countries as a repellant for what is generally known as Evil Eye. The Evil Eye was first recorded in Mesopotamia about 5,000 years ago in cuneiform on clay tablets, but it may actually have originated as early as the Upper Paleolithic age. The belief in Evil Eye is much present in the Roman times when it was named Oculus Malus, turpicula or fascinus and authors such as Hesiod, Plato, Theocritus, Plutarch, Heliodorus, Pliny the Elder, Tertullian, Saint Augustin and others often mention it in their writings.
The belief in the Evil Eye is still very much present in the Romanian society, yet it’s also spread across many cultures, from Jewish, Christian and Muslim to Buddhism and Hindu societies. Romanian ethnologist Gh.F.Ciausanu comments that “The Evil Eye, just like other diseases, is seen by Romanians as a being, an evil spirit.”
Given intentionally or not, the malevolent glare can cause yawning, headaches, heartaches, fever, back pains, insomnia and an overall feeling of exhaustion. Animals and plants can also get the Evil Eye look.
To protect against the Evil Eye Romanians have many incantations (Romanian “descantece”) and a very old one I know mentions “red garlic in the eyes of the one who gave me this spell” (Romanian “Usturoi rosu in ochii tai, celui ce-ai facut aceasta facatura”). Ciausanu also mention an old protection phrase: “Garlic between my eyes to protect me from the Evil Eye” (Romanian “Usturoi intre ochi, sa nu-mi fie de deochi!”). A garlic clove hanged with a red thread around the neck of the baby or on its cap will protect the newborn from getting the Evil Eye.
Ancient Greek and Romans also believed garlic can serve as a protection talisman against the Evil Eye. For the same reason, ancient Greeks used a triangular amulet containing coal, salt and garlic. An old Macedonian tradition says that to for the newborn to have good luck and be protected against Evil Eye and bad spirits, one must put in its clothing a garlic clove, three lemon seeds, a piece of bread and a ring.
Eric Block, chemistry professor at Albany University and author of more than 220 papers, 5 patents, 4 books, mentions the way Sephardic Jews used garlic as a way of protecting themselves against Evil-Eye. When a neighbor came and said something complementary about her neighbor’s child she would often add “May the evil eye not fall” or “let it go to the garlic.” Blocks also adds:
“Their houses were protected with crocheted bags with five tiny finger-like sacks each holding a single garlic clove. The bags were placed outside a window or in a balcony just like a mezuzah.”
The possible explanation why, as you have seen, so many cultures believe that garlic has the power to protect against us from evil or “dark energies”, including the Evil Eye, also comes from Block:
“the view that garlic and its relatives are impure and linked to the underworld suggests that these same plants are especially suited for offerings to underworld forces, e.g., evil spirits, in seeking their protection, or eliminating the evil they brought on.”
Regardless it's a Mezuzah, garlic or other herbs, potions, rituals, icarros (Peru), ancient descantece (Romania) or other symbolic objects, it's clear that across cultures the belief in what is generally called "evil spirit" or "bad energy" is a common one.