Studies have shown that there is little to no change in oxygen or carbon dioxide concentrations before and after yawning, indicating that these factors may be unrelated to the yawning mechanism.
Brain cooling hypothesis
There's a theory that yawning is a response to low oxygen levels, helping to supply oxygen to the brain. However, recent research suggests that yawning might actually serve to cool the brain.

Seonglae Cho