As it turns out, this practice is an old folk remedy for insomnia. Smelling the sulphur compound allicin can have a calming effect that helps you drift off and stay asleep all night. It sounds a bit strange that such a powerful and distinct odor can be calming, but lots of people swear it works.
One of the ways it might help is that the smell can clear blocked nasal passages and therefore improve breathing. Anyone who has tried to fall asleep with a pesky head cold knows how uncomfortable it is when you can’t draw a proper breath. But you may find that you get sick less often when you sleep with garlic under your pillow because allicin is thought to block two groups of enzymes responsible for the ability of infectious microbes to invade and survive in your body.