Both of these long pre-date according resembling the scientific method of germ theory. We’ve known that dirty water makes you sick and how to filter it for so long that the first example of a functioning sewer system I know of is prehistoric[1]. And clean water was transported over hundreds of miles through Roman aqueducts. They didn’t do that for no reason.
[1] Mohenji-Daro https://indusrivervalleytechnology.weebly.com/the-sewer-syst....
There's a big difference between water that is nice to drink and water that doesn't contain harmful pathogens, and cities that had piped water for centuries stopped killing their inhabitants from water-borne infections when scientists figured out germs existed and could be killed
Also, Roman aqueduct water had minimal lead contamination due to the high flow rate, unfortunately they used lead for a huge range of different things like cups which got lead onto people’s mouth and hands while eating etc.
Good nutrition was similarly common in many areas historically even without scientific understanding of nutrition.