Although science cannot truly explain why we are yawning, there are many theories as to why we yawn, that are just yet to be proven. Here they are:
Although yawning is related to tiredness the theory that seems to be the most valid is the one that says that yawning helps us activate our nervous system. This is essentially why yawning is contagious between mammals because as an animal is activating is nervous system and possibly due to seeing a danger, other animals are encouraged to do say. As the years passed, it became a reflex among animals even of different species.
Another common theory implies that yawning is occurring in order to cool down the brain. As a matter of fact, this is the reason yawning is supposed to be triggered in people that think out a lot of problems. This also explains why babies yawn as well, since their under-developed brain gets tired (and hot) more easily!