Low levels of human capital investment in poor countries have important implications for economic growth, distribution, and social conditions -- and competing explanations for the low levels have been suggested. The most prominent explanations cite low returns, parental preferences, cultural barriers, and resource constraints. This paper distinguishes between the explanations by drawing on the economic theory of the household to derive testable hypotheses about the role of family structure on child health. Evidence from a large household-level data set from Ghana suggests that while cultural barriers, parental tastes, and differential labor market returns matter, much of health investment is explained by the presence of resource constraints. The constraints push siblings into competition with each other for scarce resources, and relatively slight initial advantages to boys can make a large difference to the outcome of this rivalry. This explains how parents may gain from having sons while children will gain from having sisters -- with resource constraints and sibling rivalry, the health of both boys and girls increases with the fraction of their siblings that are female. The evidence suggests that labor market discrimination and cultural bias are on their own insufficient to explain the observed disparities in human capital investments. But when exacerbated by sibling rivalry, even small differences in returns can explain patterns similar to what is seen in the data. We predict that removing resources constraints in Ghana -- and thus eliminating sibling rivalry - - can in itself improve health investments by at least 20% to 30% in some households. We show conditions under which removing resource constraints can in itself narrow the gender gap.