From this article
Another theory is that yawning is another way for bodies to thermoregulate, via the action of neurotransmitters. Serotonin is an important neurotransmitter in the regulation of skin blood flow, and the thermoregulation this blood flow does. Increases of serotonin have been shown to increase body and brain temperatures, a change that causes the body to trigger more yawns, in an attempt to cool itself. The effects of serotonin on thermoregulation are especially obvious in the case of patients who suffer from serotonin syndrome, a condition caused by an excess of serotonin in their systems, usually from taking several serotonin-affecting drugs in tandem. Some of the biggest signs of serotonin syndrome are hyperthermia, shivering, sweating and vasoconstriction. This process is also obvious to SSRI (selective serotonin reuptake inhibitor) or SNRI (selective serotonin and norepinephrine reuptake inhibitor) users who experience a relatively (~11%) common side effect of the medications- excessive yawning. While the users may not be aware of it, the increased serotonin levels in their body increases its temperature, and therefore its yawn rate.
Harvard has a similiar theory but this is more related to brain cooling One novel theory is that yawning cools the brain, helping keep it at the right temperature for optimal function. In an old study in the journal Evolutionary Psychology, researchers reported that subjects who cooled their brains by breathing through their noses or holding cold packs to their foreheads — proven brain-cooling strategies — were less likely to yawn when shown videos of other people yawning.