I know, I know, the best answer is: because they are comic books.
Seriously though, let's establish all the craziness of the comic book universe, specifically talking about the Joker, although this applies to the others as well:
1) the Joker successfully pleads insanity over and over again, but seems to clearly be coherent of what he is doing
2) no prison is secure enough for him, and he keeps getting sent back to the same place where he has broken out of 100 times over
3) The citizens of New York (where Gotham City is I believe) aren't clamoring for an exception to the rule that criminally insane people don't get the death penalty
4) Not a single person has killed the Joker yet. You would think out of all the victims, that at least one would have had a concealed carry permit and taken him out in self defense. If not that, at least one would be (rightfully so) pissed off enough to kill him, either by just going out on a manhunt, or through some scheme like getting a job as a security guard at Arkham Asylum and there being an "accident". I'm not even getting into other villains here.. for all the stunts he was pulled against other anti-heroes and villains, you would think that one of them, who doesn't care about the law or morality anyway would have just ended him.
Most of the time people are considering the option that Batman himself could kill off the super villains (the ones that are mass murderers), but a more common solution, and one that doesn't seem to conflict with Batman's sense of morality, would be if he expanded the Batcave by adding a maximum security prison for super villains and kept all the most dangerous rogue's gallery there. Nobody knows where the Batcave is except the Bat-family and Alfred, Batman is a genius who could design an effective prison (let's not even go into crossovers or the JLA where there are even more geniuses that could help him), he would never be careless enough to let them out and he would be be totally immune to threats and bribes that plague Arkham Asylum and Blackgate. He could spend most of his time down in the Batcave keeping an eye on prisoners instead of out chancing death fighting them all the time. But how would he know who is bad enough to deserve being in the bat prison and not being allowed to go through the normal legal system? Pretty simple really.. if a villain killed someone they would go through the normal process. They would get put into Arkham or Blackgate like normal, but once they break out and kill anyone else then the legal system/prison system would no longer be deemed effective.