Alcohol (in the form of beer) was - for some periods in history - more safe than drinking water. The beer making process (boiling water as well as the alcohol in it) was good at killing bacteria[1]. Bacteria in water was a pretty significant problem for towns without a proper sewage system.
(Note that you'll find some internet sites claiming this is a myth. I don't find their arguments compelling at all: most seem to argue that water was drunk as well - which is no doubt true.)
[1] http://www.westsussextoday.co.uk/news/county-news/latest-new...