When people like the music, it tends to sound better to them when it's played a little louder; when a DJ wants to raise the energy level, pushing the volume up a little is one way to do that. Repeat this enough times through the course of an evening and you end up with the PA really cranked. (Many bars install limiters on the sound system, to keep over-enthusiastic DJs in line...) If you walk in from the street, the ruckus might sound deafening - but if you've been there dancing for an hour or two, your ears will likely have adjusted along the way, and it won't feel so extreme.
Another reason for loud music is that loud bass feels really good. If you enjoy dancing, that deep rumble just gets in your bones and makes you want to move. It can be kind of a spiritual experience to let yourself get overwhelmed and swept away by the music, feeling and moving in the moment, not thinking so much. A good, well-tuned sound system in the hands of someone who cares about sound quality can give you this experience without the "ear splitting" sensation.
Even if the bar has no dance floor, loud music can help create a sense of intimacy. Drowning out all the other conversations means other people can't listen in on yours, and forcing you to lean in and pay close attention to the person you're speaking with might help spark a connection of the sort many people go out looking for.
Leaving the club the silence outside sounded like my head was inside a slowly cooking porridge kettle. This disappeared in a couple of hours. Low frequency tinnitus appeared years later. I thougt first that my neighbourg must have installed a new air condition unit.