Oh i know about this too,when we usually are tired or bored,the flow of the blood to the brain slows down.As a result,the oxygen level to the brain decreases and the carbon dioxide level increases,and that what makes us sleepy. The respiratory center located in the brain sends the message to the muscles in the mouth to take a yawn and take oxygen in.This way we take in extra oxygen and make the brain function again!
The truth of the matter is nobody really knows. There are several theories, oxygen increase and CO2 decrease being one of them. Another theory is that its a social cue among animals. Some think that its a reflex that simply keeps the lungs in working shape. Who knows, it may be all three! I'm sure there are many more theories out there, but google can yield more results than I.
I heard that it was lack of oxygen, so your brain says to your body I NEED OXYGEN! And your body produces a yawn so that you will breathe in deeply... thus oxygen.
When you yawn it's because your brain isn't getting enough oxygen and when you're tired your breathing slows down and cuts down on oxygen intake
That's something I didn't know.