For the twice-born, those who belong to the three upper castes, eating garlic is prohibited. Garlic cannot be offered to the gods, it increases libido and then it remove from the meditative detachment, is tamasic and thus causes mental torpor.
The Manusmriti, the Laws of Manu, is very clear, you cannot eat neither garlic nor onion and those who do so must submit to santapana (heating vow) or yaticandrayana (the vow of ascetic course of the moon).
These two 'painful vows', the first is to drink a concoction of cow urine, dung, milk, yogurt and grass sacrificial and then remain fasting for one night. While the yaticandrayana is to eat only at midday eight mouthfuls of food offered in sacrifice to the gods.
According to legend garlic was born during the Samutramanthan, the struggle between gods and demons for the soma, the drink of the gods which gives immortality and power, which had emerged from the samutramanthan.
You will remember that the demon Rahu (click here) for a while managed to get hold of the drink and drank a bit, but Vishnu cut off cleanly the demon head. Well, a few drops of the soma fell on the ground and from there came the garlic.
For this reason, garlic is a food forbidden to the upper castes and especially to the Brahmins, because in some way derived from an animal, in this case by a demon.
Yet Ayurveda, the traditional Indian medicine, consider garlic as a powerful medicine. In fact there is even a medical treatise entirely dedicated to garlic.
Vagbhata, in his treatise on Ayurveda, remember that garlic cure fractures, cures vitiligo and leprosy, haemorrhoids, worms and urinary tract infections, coughing and palpitations, increases strength and rejuvenates.
Obviously treaties ayurvedic know the problem of impurity of garlic and also have a unusual solution to make it pure. Here it is.
You must make fast a cow for three nights, then you must feed it with compound feed for two parts of grass and for a part of garlic. After that the Brahman can drink milk and eat butter of that cow and could take garlic to cure his diseases.