I’d personally hypothesize that yawns, like almost all other emotional displays (smiling, laughing, worrying, eye dilation) are simple pre-language communications. It’s useful for a pack of animals to know when one animal is tired - yawning is contagious because it’s advantageous for the pack to have a similar sleep schedule - and to be aware of how each other feels. Our faces display our emotions clearly as a form of communication to others. We developed whites in our eyes, for example, so we can track the attention of our pack-mates. It's easy to forget that biologically, spoken language is a brand new invention - but communication is extremely ancient.