Nobody waved a wand. The contaminated milk that killed infants killed adults too - alcohol and milk were alternatives to unsafe water. Public health, medicine and other factors improved things.
We don’t really have great stats from before the 19th century. Was 1850 a nadir in life expectancy? I’m not sure - but I suspect it varied by region and rural/urban conditions. 1750 NYC wasn’t as gross as 1850.