Although it may sound like a psychological disorder, geophagy is a useful habit acquired by many animals and certain populations of people. The eating of dirt can help protect an animal from toxic components of plant material.

Plants naturally do not want animals consuming their seeds, leaves, stems etc. As a result, the plant kindgom has developed a fantastic array of chemicals that are bitter or even toxic to would-be foragers. Still plants, and particularly seeds, are good sources of minerals, vitamins, carbohydrates and even fats that animals can use, so some have taken on eating of dirt to help alleviate the toxic effects. Soil contains minerals that can often bind up the plant toxins. Animals ranging from insects to parrots to deer will seek out dirt that is the most effective at binding up a particular plant toxin and ingest it along with the plant matter.

People have discovered the mitigating effects of soil as well. In South America, some Indians will eat bitter, toxic potatoes that would normally induce vomitting and serious gastric distress in people. However, they have found that eating certain clays bind up the toxic alkaloids in the potatoes, rendering them harmless. In California, Native Americans used to mix acorn flour with a clay that binds tannic acid which normally makes acorns difficult to digest.

Geophagists may also be searching for a good source of minerals. Soil can be rich in elements like sodium or calcium and animals or people may eat dirt to satisfy mineral cravings. In Zambia and Zimbabwe, pregnant women eat the dirt from termite mounds (which also attract local cows and giraffes) in order to accomodate their body's newfound demand for minerals.

Resources: http://www.uic.edu/classes/osci/osci590/8_2DirtasFood.htm