Some horses will develop a habit of eating manure. There are several common reasons this occurs.
Foals eating Manure:
In foals one week to several months of age, eating manure is a way for them to jump-start the good bacteria in their digestive tract. As long as it doesn't become a long-term habit, there isn't any reason to discourage coprophagy in foals.
Mature horses will sometimes develop coprophagy out of sheer boredom. Just as some horses crib, some weave, others pace... Horses can develop the habit of eating manure in their stall, or even out in the pasture, when they become bored. This behavior may not be detrimental to the horse, but you can talk with your veterinarian about checking for other causes for the behavior, and what can be done to stop it.
Some horses will begin eating manure because their diet is lacking. If this is the case, it's important to pin-point what it is your equine is missing, and solve the issue. Proper nutrition is key to keeping your horse healthy.
If an equine is hungry, not starving or neglected, just currently having an empty stomach, they may develop a short-term habit of eating manure to temporarily ease their hunger. Keeping some form of roughage (hay, pasture, etc.) in front of your horse should stop this habit in it's tracks.
*If your horse is eating manure, contact your veterinarian to definitively find the cause of the behavior.