The FOB is not waterproof, and if it gets fairly wet (ocean, washing machine, heavy downpour, etc.) it will die. If you catch it quickly, try removing the battery, and putting the FOB in dry rice for 24 hours, so that it might dry it out enough to keep working. In most cases, it will be dead even with a new battery and will necessitate replacement.
There are a number of solutions suggested by others, including using a zip-lock bag (for surfers), using stretchable rescue tape around the fob, or using Plasti-Dip. The Tesla forum thread on Securing the Model S for Surfing does a good job of covering the details. The rescue tape and Plasti-Dip are both easily removed if needed to replace the battery and does not stick to the FOB itself. Plasti-Dip is available in select colors, but black may be best. Clear is sort of light-yellow translucent.