No, Medieval people didn't drink booze to avoid dirty water 
It seems to be common wisdom that Europeans in the Middle Ages drank primarily beer and wine because water wasn't generally safe to drink. This, however, is a rather persistent myth as water was a regular part of the Medieval diet.

Food historian Jim Chevallier examines what he calls "The great Medieval water myth" at his blog Les Leftovers. He cites a handful of modern writers who have specifically examined water in Medieval Europe, including Paolo Squatriti, author of Water and Society in Early Medieval Italy, AD 400-1000, and Steven Solomon, author of Water: The Epic Struggle for Wealth, Power, and Civilization, and looks back at primary sources from the time, which, he says, are always uncritical when they mention the drinking of water.

He notes that some Medieval writers laid out instructions on how to tell bad water from good (and sometimes even recommended boiling water that smelled iffy), and mentions one physician who recommended against drinking too much water....MORE
Although the story has a pretty good picture to illustrate it there are better ones they could have used:

(Image of a serf using a primitive beer bong from the Luttrell Psalter)