Tannins are astringent, bitter tasting compounds. Chemically, tannins refer to a broad class of polyphenols. They are often differentiated from other polyphenols in that, tannins precipitate proteins. Ann Hagerman at Miami of Ohio University has a great pdf online that explains tannins much better than I could.
They are not desired in beer. However, they are found in the hulls of the grains whence comes the goodness that eventually becomes beer. During the mashing process, the starches get enzymatically broken down to maltose. However, if the mashing or sparging water is too hot, detrimental amount of tannins can be leached from the grains. It is well known that for most things, the solubility in water increases as the temperature of the water increases. So, this makes sense.
However, the pH of the mash can also affect the solubility of tannins. If the pH is too high (the "normal" pH of a mash is around 5.2) the solubility of tannins increases. This has to do with the presence of the phenolic functional group.
Shown is catechin, a common (and fairly simple) tannin found in a brew kettle near you [edit: The structure shown is missing one OH group. I'll fix it later].
As any sophomore organic chemistry student will tell you, the OH groups bonded to the aromatic rings (the group that puts the "phenol" in "polyphenol") are willing to lose their protons to a base. The pKa of phenol is about 10. I don't know what it is for catechin, but I'm sure it is in that vicinity.
As a result, if the pH of the mash get too high, more and more of the tannins will lose the proton. The result is charged, ionic compound which has a higher water solubility than the neutral species. As a result, the result of this result results in more tannins dissolved in the water.
So, what affects the pH of the water in the first place? You'll just have to wait and find out.