When our brain gets hot, we cool it through the mouth, and the best way to cool through the mouth is by yawning.
Researchers showed this by cooking parakeets.
Okay, they stopped short of actually cooking them, but they found that when temperature increased, the parakeet yawn rate doubled (there was no description of researchers' yawn rates).
This fits with our understanding of yawning as a symptom of thermoregulatory diseases. We yawn in the lead up to epileptic seizure (hot electricity in the brain). Yawning can also presage migraines. In multiple sclerosis, the myelin surrounding nerve axons is damaged, and hot electricity leaks out—and many MS patients experience bouts of excessive yawning.
And it’s no coincidence that we also yawn when we're tired: exhaustion and sleep-deprivation increase deep brain temperature.
If you're against boiling parakeets or otherwise harming helpless creatures like kittens and maybe ponies, please consider buying a copy of my new book, Brain Candy.