Cows sense the Earth's magnetic field and align themselves to face either north or south when grazing or resting. Studies show that most cows face a north-south direction, regardless of other factors like the wind or the position of the sun. This ability is called magnetoreception.
The study took 8,500 cows in 308 pastures around the world into account, using satellite imagery. Contrary to popular belief, the study found that cows do not align themselves in a way that protects them from the wind. The study also focused on deer, which naturally rest in wind-protected positions. The deer also faced a north-south position. Without sun, wind or temperature being common factors for the herds of cattle and deer, scientists found that the magnetic field was the only common factor between them.
Other animals have internal compasses as well, and use the Earth's magnetic field as a spatial cue. Bats and birds use this internal compass when migrating or in flight. Researchers aren't clear why cows and other mammals, such as deer, have this ability, or why it benefits them. One theory is that it is simply a leftover trait from ancient ancestors that had to wander to find food and water.