The idea that medieval people drank beer because it was safer to drink than water is actually a myth. Here's a post by /u/sunagainstgold that discusses it.