For the most part of Jakarta's history, the city's state owned water company never claimed that the piped water are actually potable. People with money resorted to buy bottled water for all their water needs, and people with less means resorted to using groundwater.
I believe that even large apartment complexes in Jakarta are pumping groundwater simply because the water company is so unreliable. I know for a fact that a large housing development near Jakarta even have their own pumps, pipes, and distribution network. Such is people's distrust of the state's water company. In fact, my parents used to draw from groundwater as well.
The amount of groundwater being used means that more seawater seeps in, and the displaced groundwater resulted in parts of the city slowly sinking into the ground.
In short, Jakarta was originally a Dutch port that was never meant to be a capital of anything. It is well past its use-by date, and was definitely never designed to fit millions of people.