Yawning is considered a social behavior. While fetuses were known to yawn, scientists weren't sure if it was a self-contained reflex or if they could somehow detect cues from their moms
From Reddit - r/science: Study suggests yawning may help move cerebrospinal fluid and venous blood out of the skull, potentially playing a role in cleaning brain fluid