science has never been able to explain why animals and people yawn. there have been hypotheses of a varied sort, everything from increasing oxygen consumption to regulating body temperature, but evidence to support these theories is shaky at best.
i think the answer lies not in physiology but in behavior. when an animal yawns, its jaws are stretched as wide as they possibly can. this is a common action of many animals when they feel threatened or vulnerable, to open its mouth wide, bare teeth (if they're of the toothy variety) and generally try to present an intimidating visage. it would make sense for this behavior to be an instinctive ritual for tired animals about to go to sleep. by instinctively yawning before laying down, the last impression they make upon the world is one that very clearly says "don't you DARE mess with me!"and this could be a healthy deterrent to any would-be predators that could be lurking nearby.
i think this also explains the classic "contagious yawn" phenomenon: social animals, which humans definitely are, take behavioral cues, particularly those which act on a level of involuntary instinct from each other. seeing one person/animal yawn would communicate subconsciously that it's time for the entire group/herd to lay down, and would trigger the same yawn-before-rest reaction in the other members of the group.
anyone with an legitimate background in biology wanna refute my theory, or does it actually have merit and potential?