We usually yawn when we are tired or drowsy. Sometimes we yawn to wake ourselves up. "The motion helps stretch the lungs and their tissues, and it allows the body to flex its muscles and joints.", This is taken from heathline.com. I would go there to do some more research on this topic.