Why must a baby take a breath immediately after birth?

Need to breathe. Once the baby is out of the womb, they need to supply their own oxygen by way of breathing (previously they were getting oxygen from mom via the placenta). Those first initial breaths are also important to cause necessary pressure changes in the baby's heart and lungs, so that the baby's own circulation system begins to work properly.