Good answers here. Here are a few more points to chew on.
Batteries in submarines are wired up in an array, or series parallel connections. With the robustness of lead acid batteries this is not particularly problematic.
However, with more modern batteries that are much more sensitive to temperature effects especially during charging, it becomes more and more difficult to have the whole array operate safely as you increase the array size. Each battery needs to be monitored individually during charging. That significantly decreases the reliability of the whole.
Further, a failing battery in the array can quickly be driven into a dangerous condition by the remaining batteries. Special measures need to be in place and effective to deal with that. Again, down goes reliability.
Energy density, although seemingly a good thing, it is also "a double edge sword". If you can get all you power from something the size of a shipping trunk compared to a room for lead acids, that is all well and good. However, now you have to extract and get rid of the heat that is generated in that battery pack. Being that much denser means you have much less surface area and that makes it a more difficult proposition.
One more thing. One of the criteria of military anything is serviceability. Lead acid batteries are everywhere. If need be, a sub crew can scrounge some batteries from trucks and the like to do a quick repair, and set to sea again. Finding exotic batteries in some atoll in the middle of nowhere.. not so likely.
As for chlorine gas release. Yes that can be an issue with lead acid batteries but it is a small risk compared to chain reaction of exploding high tech batteries. The battery compartment can be gas sealed, the crew is trained on the use of gas masks, and gas leak sensors give plenty of warning to allow the commander to perform an emergency surface procedure if he deems that is safer than the alternative. Yes it's nasty stuff, but of all the risks our intrepid submariners endure, it is one of the less likely ones to affect/kill them.