people have long known about clean water tho. Like, in about 400 bce Hippocrates (of hippocratic oath fame, which iirc was originally much more about preventing medical guild wars by swearing to only do your own kind of medicine) used to boil water and then pour it through a filter to use for washing patients etc.
From around the same time in India, texts have been found also saying water should be boiled and poured through a filter
Central America had filtration systems for water that are very similar to some we still use today, specifically ceramic filtration.
In Arabia they used wick-filters, which i find interesting, whereby water gets pulled through a material via the natural wicking properties of the material itself. Depending on the material, this can be sufficient to remove almost any bacteria, but not viruses. Still, pretty good.
The medieval european period did have a lot less science going on in general, and specifically in the area of water purification, which was mostly centered on trying to make the water look clear via visible particle filtration. Some people in some areas did also boil the water, and it was generally understood that rain water was cleaner than most other water, tho rainwater is not by any means sterile (and modern rainwater is pretty polluted from human activities and is even less safe to drink that it used to be). Still, they knew clean water was important and did make some effort to purify their water and be clean.
For example, many people in medieval europe habitually washed their hands before eating, and, while they didn't use boiled water or soap, simply scrubbing your hands thoroughly and energetically in fresh water will clean your hands of about 70% of the germs on them, which is a lot better than nothing, and while they couldn't say much about germs or a percentage of them, they did know that washing your hands was healthier than not washing them.
And in the renaissance era, it again depended on where you were and exactly when. In 1143 Portugal, one monastery founded the Cistercian Order (or like, the Order of the Cistern - a cistern is a water tank) and they had a rainwater collection and purification system and a sustainable sewage system including an effective waste-water treatment plant to make waste-water safe enough to use in the garden, so there were definitely some pretty decent understandings of water cleanliness going on there.
Anyway, ancient people definitely recognized the value of sterile water and often knew how to accomplish it.
The ancient Egyptians used to sterilize their medical tools with just literal fire or high temp ovens (which does sterilize them). They often additionally used antiseptic substances to rinse them, and also to treat wounds. As well, though this was likely more due to availability, their surgical instruments were usually copper, which is a natural anti-microbial material.
Humanity has been working toward our modern scientific and hygienic knowledge for a long long time; we owe a lot to the many thousands of years our ancestors spent developing these things.