In the medieval ages, peasants used to drink beer instead of water because the plain water wasn't safe to drink. Why do people in countries where the water sources are polluted not do this today? Why did this practice emerge in some countries but not others?
"In the medieval ages, peasants used to drink beer instead of water because the plain water wasn't safe to drink... Why did this practice emerge in some countries but not others?"
One really good reason is this -- it's not true in the first place. It's a myth, and a very common one. People didn't use spices to cover up the flavor of spoiled meat, either!
This recent well-sourced blog post by Jim Chevallier (a food historian) discusses the topic, including quite a few period quotations, such as:
The post also links to another post, discussing the words of a fourteenth-century monk:
Certainly people did drink beer, but most likely, this was because they liked it, not because the water wasn't safe.
Chevallier also suggests that the drinking of water just didn't get recorded much because water didn't need to be sold, taxed, etc.
So, in the context of your question -- people don't drink beer instead of water now to avoid bad water (at least, not much) because that isn't really something that typically happened in the first place. People now often drink Coca-Cola and other carbonated beverages if they don't want to drink water, and modern beers are pretty strong, unlike small beer and the like.
Medieval people may not have understood germ theory and so on, but they did place a high value on cleanliness. There's a bit about that in Chevallier's post too, but I don't want to end up quoting the whole thing! One thing, though -- at least some medieval people did in fact know that boiling water could be helpful. Paulus (admittedly early Medieval -- 7th century) said:
The practice of drinking beer instead of water was because people noticed that you would get sick less. Why was not understood until the 19th century, with the advent of modern bacteriology etc.
Since we now understand that it's non-clean water that makes you sick, clean water is a high priority around the world. Clean water is always cheaper than beer, so everyone who can afford beer can today afford clean water. Therefore you no longer drink beer instead of water for health reasons.
Also, the practice to drink beer was a mainly European affair. In Asia it was instead tea, which like beer involves boiling the water.
Quite a few countries with bad water are also countries ruled by rather aggressive religious regimes that ban the drinking of alcohol, and will go so far as to behead or stone people found in posession of it.
Certainly, as other posters have implied, cultural differences may play a role. For the much of the Islamic world (although this did vary over time and space, as it does today [compare modern Saudi Arabian alcoholic asceticism with the Tunisian belief that God had given the Tunisians special dispensation to enjoy the date wine and spirits made in the area]) it would be difficult to countenance fermentation processes as a way of sterilizing drink.
Next I think it is important to note that precisely what the brewing process was doing to beer cannot have been understood much before the 19th century. And it is also clear that over indulgence in alcohol could have deleterious effects, physically and socially, so I wonder how obvious the connection would be to the mind of someone living 1000 years ago. Alcohol had benefits, but also drawbacks. Over indulgence can even make you more susceptible to disease. We might then view the adoption of alcohol as a prophylactic strategy as comparable with something like sickle cell anemia. Given the prevalence of malaria in South America, sickle cell anemia can help to extend life. Given a different environment in which, say the anopheles mosquito struggled to survive, sickle cell anemia is likely to shorten, rather than prolong, life. Water purity, and the kind of microbes found in certain water sources, may vary between geographical locations. So, if you have a well run city, with decent drains and the whole civic architecture of aqueducts, deep sunk wells, fountains etc., would alcohol seem like a necessary prophylactic measure?
A final thought would be about the social apparatus required to brew on a large scale. Firstly, whilst it is clear that there are alcoholic drinks brewed by non-agrarian societies, a large supply of grain is usually helpful. Secondly, you have to control the alcoholic content of the beer quite carefully. You need to be able to offer the drinker a "known" quantity of alcohol, because he still had an afternoon's work before him etc. You also had to regulate the alcohol suppliers - if you can't trust your landlord, how do you know that the beer you've just bought isn't watered down (with potentially dangerous water) anyway? Finally, Europe is just one of those places around the world whose recreational drug of choice was alcohol. In societies in which opium or cannabis or cocoa leaves etc. were more prevalent recreational drugs, I suspect a fuller investigation is made into their properties in general - Europe may have been brewing high quality beer since the middle ages, but if you were about to have a serious medical intervention, the greater access of middle-eastern cultures to powerful analgesics like opium might seem a powerful incentive to live in an alcohol free culture.
The contrary case is also interesting, and serves to make a point about what it is that limits the spread of public health technologies like sterilizing water. Given that boiling is a relatively low cost activity, requiring only fire, a suitable pot, and some water, and that brewing is, by comparison, labor intensive and produces a result which contains a potentially unwanted side product, alcohol, why was water boiling not a prevalent prophylactic method in Western Europe? Realistically speaking, it can't be that the sterilizing effect of boiling water was somehow different a few hundred years ago. Instead, since we know that boiling water does have this effect, the limiting factor must be recognition of boiling's role in the process. Precisely because boiling was not recognized as the cause of the change in the drink, boiling as a sterilization technology is not something that Europeans could have offered. Perhaps the same is the case with tea or other boiled drinks - if you believe it is the tea leaf, rather than the preparation of the water, that makes tea better for you than untreated water, then you perhaps you already think you know the answer. Today what we regard as the correct answer, boiling, means, as my critic (see below), Lennart Regebro, has indicated, that prepared water is more commonly used, since brewing is a more labor intensive process for the same result. Boiling is often not enough, however, and there are now available various water sterilizers in various forms, including tablets etc. In general, water is also to be preferred not merely for health reasons, but also because it doesn't cause intoxication to the same degree.
I guess one interesting question would also be about the role of fire in purification rituals. If heat was known to be a purifier, religiously and morally (fire in judicial practice), and alchemically, it is surprising that it was not believed that heating water produced a beneficial effect.