Females live a lot longer than males in most parts of the world today. But that was not always the case. We ask when and why the female advantage emerged. We show that reductions in maternal mortality and fertility are only partial reasons. Rather, the sharp reduction in infectious disease in the early twentieth century played a role. Those who survive most infectious diseases carry a health burden that affects organs and impacts general well-being. We use newly collected data from Massachusetts containing information on cause of death since 1887 to show that females between the ages of 5 and 25 were disproportionately affected by infectious diseases. Both males and females lived longer as the burden of infectious disease fell, but women were more greatly impacted. Our explanation does not tell us precisely why women live longer than men, but it does help understand the timing of their relative increase.