Your battery exploded because it had a short in it. Hydrogen is powerful explosive but probably not powerful enough to blow your battery apart UNLESS it exploded from inside. Without researching it, I would say that your battery was needing service, and your charger was trying to charge it. You had a short in one of the cells which finally got hot enough to ignite the hydrogen created inside your battery. The top was blown off as a result.
My advise to you (advice is worth what you pay for it, in this case nothing) I would be sure to wash down the inside of that battery compartment thoroughly, more than once, I would use common soap and water then a mixture of baking soda and water. let it dry then rinse again thoroughly, Then I would get some WD 40 or such, perhaps even some corrosion proof oil from the electrical department at lowes and spray it down thoroughly. Once all that corrosion has been halted I would use Krylon industrial primer to paint all metal surfaces.
Depending on how much damage has been done, your insurance company may pay for it. they won't pay for the battery but they will damage from an exploding battery. Fortunately you were not hurt. BTW look at true deep cycle house batts for your rig the next time you buy batteries. Trojan, Continental, are just 2 among many industrial batteries. The 31 Everstart MAXX is not a good house battery and is not necessarily a deep cycle batt it is a multi purpos starting battery for vehicles that have large electrical systems. Next time you need a house battery look to an industrial supplier of deep cycle batteries. Trojan and Continental are just two brands, there are many.
Good luck
I replaced my 12 volt battery before my latest trip as the landing jacks would not work without me plugging in the 50 amp service. So I figured the battery was dead and I knew I needed it for proper service. I took the whole rig to the local battery dealer and let the kid there do the labor of pulling the battery out. He opens the box and says " Whoaaaa, you gotta see this!" The battery had exploded in the box and the top was blown off. He cleaned it all up and replaced the battery with a size 27, not sure if that is a common size or not but then he looks at the extra room in the box and says he can probably fit a 31Max in the compartment. I told him to go for it. He says the 31max is the largest deep cycle available ? Not sure if that means where I live or anywhere? But the battery worked great for my trip. I also noticed that the battery did not have wing nuts. The dealer says the EPA has made the battery companies switch to nuts on the threads to eliminate the possibility of loose connections. He said a loose connection can arc and if there are battery fumes in the box your battery will explode. Well. Now I know.