When babies are premature, females have more mature brains and are usually much better off neurologically, so they're more likely to survive. The evolutionary reason for this is that females are much more precious to a society because of their childbearing potential, but men are expendable (since one man can impregnate multiple women). Because of this, brain development is built more to spec and much more precisely in females, meaning that there's less variation in how girls' brains develop.
Although the exact reason is not known, it is assumed that the hormones that make are unique to girls at birth also help mature the lungs and other organs (brain, intestines) in baby girls which improves their chance of surviving. While survival of girls is better than boys, the difference is relatively small and many other factors also play a role in survival.