Beer being a way of drinking uncontaminated water is a myth that somehow sticks around, similar to the belief that people in the middle ages thought the world is flat.
Fresh water outsiderof cities was abundant, and inside cities there was usually a system of wells, often running water wells at that.