Meaning and benefits of noisy exhaust systems?

Good day, according to my technical understanding of cars, the exhaust system should, among other things, fulfil the function of releasing the combustion gases to the environment as quietly as possible through a sophisticated geometry of this system. Unfortunately, I often find myself generally in the city and especially on the relatively busy road, where I live, that some vehicles run out of disproportionately loud noise, in individual cases even in a hearing loss. Is this even lega l and if yes, does it bring a technical benefit or advantage? Or does this only serve to polish up a cracked ego as well as to compensate for mental/anatomical deficits? I ask for a factual and rational answer.