To prevent an explosion
When you are charging your car battery, the chemicals within start to hydrolize, creating Hydrogen gas. If it builds up while electricity is running through the battery...not only could it could explode, but it could spray corrosive acid.
I haven't seen it personally, but there has been a case where the top of the battery shattered, thank God the mechanic had goggles and a jumpsuit, but there were holes in his suit and the paint of the car.
Note that this is more of an issue for old-school batteries. Some new ones don't even open up, others have removable caps. A "maintence free" battery is sealed, thus you can't top off the water in the battery.
Kudos to Popular Mechanics August 2001 for pointing this out, and Psychonaut for the additions.