All babies are known to yawn in the uterus, although the reason why they do this remains unclear. Yawning is often accompanied by shrugging of the shoulders or stretching, exactly as you would do when tired. Unborn babies have even been seen to rub their eyes!
Your baby first started yawning at around 15 weeks and has gradually yawned more and more frequently. The precise function of yawning for the baby remains in doubt and there are several hypotheses. While it's difficult to imagine that an unborn baby is actually tired, it has been found that babies who are anemic yawn much more frequently than others. Another theory is that yawning may help the unborn baby to regulate the amount of fluid or blood flow he has within his lungs. Or yawning may simply be a primitive reflex, a remnant from an earlier evolutionary stage, with no current function.
Whatever the reason for yawning, the early stage at which this develops in the unborn baby, and the fact that all mammals are known to yawn in the uterus, does suggest that it plays an important, though unknown, role in fetal development.