As noted by Olivier Walusinski:
"Yawning is a stereotyped, and often repetitive, motor action characterised by gaping of the mouth accompanied by a long inspiration of breath, a brief acme, and then a short expiration of breath."
Yawning has been documented in broad range of vertebrate species -- even fish. It has been observed in 20-week old human fetuses. So it's a behavior with deep biological roots. But despite years of research, there is still controversy as to what function it serves. As Adrian Guggisberg and his colleagues have argued:
The only specific effect of yawning that could be demonstrated so far is its contagiousness in humans, some non-human primates, and possibly dogs, whereas all studies investigating physiological consequences of yawns were unable to observe specific yawn-induced effects in the individual of any species.
Some old physiological theories have been ruled out. For example, it was once proposed that yawning was a response to brain hypoxia (low oxygen levels). But when researchers subjected volunteers to different air mixtures to breathe -- containing differing levels of oxygen -- they found this had no effect on yawning frequency. Yawning can make your ears "pop," or adjust to changes in altitude. But so can swallowing, so it's not clear that yawning exists for this reason.
Three hypotheses still under scrutiny include the following:
(1) Yawning is a way to increase vigilance
Some researchers propose that physical movements associated with yawning compresses the carotid body in the neck, which may then trigger the release of hormones that increase arousal and vigilance. The evidence, however, is mixed. One set of experiments show that people who yawn show the same changes (in skin conductance levels and brain waves) that are found in people who have consumed caffeine. But another experimental study failed to find such differences.
(2) Yawning cools the brain
Experiments on nonhuman animals suggest that yawning temporarily decreases core body temperature, and individuals yawn more when they suffer from medical conditions that cause elevated core body temperature. So some researchers speculate that the function of yawning is to lower body temperature and cool off the brain. But others, like Hanno Elo, are skeptical, arguing that yawning couldn't lower brain temperature unless it somehow induces water evaporation, something that hasn't yet been demonstrated.
(3) Yawning functions as a social signal
A variety of evidence shows that individuals are susceptible to "contagious yawning," responding to observing a yawn by yawning back. In human children, this reaction develops in conjunction with the emergence of "theory of mind," the ability to understand and distinguish the thoughts, motives, and feelings of other people.
There is also evidence that the power of social yawning depends on your relationship with the demonstrator. In both humans and chimpanzees, studies report that individuals are more likely to mirror a yawn when they have a close relationship with the yawner.
In one study of people from a variety of cultural backgrounds, researchers found that "the social bond had a strong significant effect on yawn contagion," with contagious yawning being the strongest between family members first, close friends second, acquaintances third, and strangers last.
If yawning is a social signal, what does the signal mean? One hypothesis is that it functions to tell others that you are shifting into a less aroused, more relaxed state (Liang et al 2015). This suggests that the spread of yawning through a group could represent the transmission of message that everyone is settling down to rest. But this, too, is subject to controversy. For instance, opponents of the hypothesis say it doesn't explain why people yawn frequently after awakening.
Gallup AC and Clark AB. 2015. Commentary: Yawning, acute stressors, and arousal reduction in Nazca booby adults and nestlings. Front. Psychol. 6: 1654.
Gupta S and Mittal S. 2013. Yawning and its physiological significance. Int J Appl Basic Med Res. 3(1): 11–15.
Guggisberg AG, Mathis J, Schnider A, Hess CW. 2011. Why do we yawn? The importance of evidence for specific yawn-induced effects. Neurosci Biobehav Rev. 35(5):1302-4.
Liang AC, Grace JK, Tompkins EM, Anderson DJ. 2015. Yawning, acute stressors, and arousal reduction in Nazca booby adults and nestlings. Physiol Behav. 140:38-43.
Walusinski O. 2013.Why Do We Yawn? Past and Current Hypotheses In: Hypotheses in Clinical Medicine, M. Shoja and S. Agutter (eds).