LouisJolliet's answer, above is correct. There is a bit of side-benefit as described by ILuvAmericanBulldogs's answer. However, a small amount of moisture will not normally cause a microphone to malfunction..
It's a wind screen and a pop filter. It serves three primary functions 1-keep spit from getting into the mic. 2-mitigate the effects of "popping" harsh consonants like the P, K, and T sounds and "hissing" the S and Z, and any other vocal sounds that involve a quick harsh burst of air from the mouth like CH and SH. 3-a windscreen to keep wind from overpowering the mic especially in outdoor performances.