Budgies, sea lions, and chimpanzees all yawn. Spontaneous yawning is older than singing, making it one of the most anarchic forms of communication. Contagious yawning has nothing to do with normal yawning. We observe it only in creatures that live in social groups (for example, humans). In evolutionary terms, it is therefore much younger and has a different function than normal yawning.
In fact, yawning has nothing to do with the person yawning being tired or sleepy. Rather, yawning is a cooling mechanism for the brain, because its work generates immense heat in the brain. For the brain to function optimally, it must not overheat. In other words, yawning serves to cool the brain so that it can continue its work without interruption or disturbance.
In experiments conducted in Salzburg, Stockholm and Chicago, we found that people yawned less in winter than in summer. This is because yawning is a physiological counter-reaction to overheating of the brain. The deeply inhaled air cools the arterial blood. Blood flow to the brain is stimulated and warmed blood drains better.
When we analyzed the yawns more closely, we also found that the larger the brain mass and number of neurons, the longer the yawn. This means that a large upper brain produces more heat and requires longer yawns. In our case, the event lasts between four and seven seconds.
It also fits that people who suffer from a disease that affects the temperature balance of the brain sometimes suffer from regular yawning episodes. Migraines are sometimes preceded by compulsive yawning. People with epilepsy and multiple sclerosis are also familiar with yawning, so much so that some people suggest using yawning as an early warning sign for drug treatment. But there are (still) doubts.
The contagious yawn has nothing to do with that. It used to be felt as deep compassion when a person yawns in community and then others yawn too. But that is not the case. As we now know, yawning helps to balance the activity in the group. Yawning, which even babies do in the womb, is an important social signal to balance rest and activity within the group. Thus, yawning is a signal of harmony and unity in the community.