Many ancient civilizations had to bring clean water to their cities because they had polluted the rivers where they lived. The earliest civilization to do this was in the Indus valley (now Pakistan), but the Greeks, the Mayas, the Romans and others all had very complicated and effective means of getting clean water to their people.
The Mayans, for example, who lived in part in an area without surface water, collected their water in vast covered reservoirs. The Romans used aqueducts and pipes, and many people in the Middle East used underground watercourses direct from mountains.
In fact they also had the advantage of living in areas where there was a water shortage for at least part of the year and so they had either to dig deep wells to get to their water or they had to bring it by aqueduct from places where there were few people. Both things led to the use of clean water and incidentally kept disease down.