This behavior is known as “cribbing”. There is evidence that cribbing releases chemicals in the brain known as endorphins. Some horses learn to arch their neck and swallow air without needing to grasp an object with their teeth, but this is rare. Some horses will also get into a habit of chewing wood.
Cribbing can result in several unhealthy outcomes. Grasping and pulling on hard objects can wear down the teeth or damage them. The pulling motion, if frequent and intense, can result in abnormal neck muscle development. Some claim that pain (from colic or ulcers) causes cribbing. Horses that crib do seem to have a higher frequency of colic and ulcers than the normal horse population. However, research suggests that horses fed grain rather than pasture and/or those fed 1 or 2 times per day rather than multiple times, are more likely to get ulcers or colic. I believe colic does not cause cribbing and cribbing does not cause colic, but both can be the result of unnatural feeding.
Cribbing is a compulsive habit, probably the result of boredom and/or anxiety. Not all bored or anxious horses will develop this habit but is most common in horses kept in their stalls, or small enclosures, for long periods without adequate mental stimulation. If a horse cribs, other horses may copy the behavior. Once the habit becomes ingrained, it can be difficult to correct. Because cribbing releases endorphins in the brain, it is, effectively, a drug addiction. As with any drug addiction, kicking the habit is hard. Here are some recommended treatments:
1) Provide mental stimulation, additional exercise, training, etc. Occupy more of the horse’s time.
2) Remove the horse to a more enjoyable environment such as a pasture with other horses. Providing pasture time will usually reduce the frequency and intensity of cribbing, but may not stop it.
3) Paint the objects that the horse grabs with something that tastes unpleasant. This is most effective when combined with providing lots of pasture time. There are a number of products designed for this purpose as well as many home made recipes. Make sure that what you use is not poisonous.
4) If your horse cribs on fences, putting an electric wire along the top of the rails might work.
5) Fit the horse with a cribbing strap. This collar will prevent, or make it uncomfortable for the horse to swell its neck to suck in air.
6) Calming medication, usually anti-depressants, but I don’t support behavior modification with drugs.
7) Fit the horse with a special muzzle that allows it to eat but not to grasp with his front teeth. I have seen something like this but have no idea where to find one.
8) A last resort is surgery to cut the muscles used to arch the neck.