The locals typically have the same type of "flora" in their digestive tract that you'd find in the water and are used to it which is why it doesn't affect them. One of the reasons you may feel "off" when you're in other (typically developing) countries is because your body is exposed to different bacteria which start to wrestle with your existing and quite happy bacteria. When that happens all hell can break loose and by loose I mean loose. Sometimes Montezuma is more than that like potentially crypto or other things that would affect even the locals but typically it's just the mild wrestling type. Its uncomfortable but can be avoided by following the suggestions in this thread.
I travel to rural Mexico 10-12 times a year and have NEVER seen the locals drink the tap water - ever. They will many times go out of their way to warn you about drinking it as well. They all buy Agua-Pura for drinking and cooking.
They only use the tap or delivered water for washing, bathing and watering their plants.