Happy cows are milking cows, according to this U.S. study.
When the amount of calcium in an animal's bloodstream decreases, the animal can enter into a state of "milk fever," causing a chill and trembling. Low calcium levels, in turn, make these animals more prone to other diseases.
Serotonin works to increase the amount of calcium in the blood. The hormone then circulates in the brain. Low levels of calcium are often linked to depression in humans, and the same could be said of cows. Therefore, more serotonin means more calcium and better circulation, which means the animal is healthier and produces more milk.
Even stressful situations can decrease happiness, so maintaining a positive, calming, enriched farm environment can keep your cows healthy and the milk flowing.