The Short Version
This claim is false. The idea that yawning exists to increase oxygen intake has been largely abandoned by the scientific community. Controlled experiments show that changing oxygen or CO₂ levels does not affect yawning frequency. While yawning does involve a deep breath, this is not its purpose. Current research points instead to brain cooling, sleep-wake state transitions, and arousal regulation as the primary functions of yawning. The "before sleep" framing adds an additional unsupported specificity.