There is a kind of punishment that is beneficial to society, but not beneficial to the one being punished, which would be separation. If someone refuses to acknowledge their wrong doing as problematic for others, they should be separated. This is the idea of a "time-out" and it is the best reason for prisons. This safeguards those who might be harmed by anti-social behavior.
The other reason for punishment is karmic justice. Some say that karmic justice reduces wrong-doing by helping people realize that their crime has a consequence. That assumes rationality in those doing the crime. Many crimes are done by compulsion, such as crimes done in rage or under an addictive drive. Those crimes aren't done rationally and so karmic justice doesn't prevent a single one of those. Many feel that it is just simple justice, "eye for eye".
However, I find that karmic justice is rarely just when accomplished by human beings. Humans often overpunish or do not know enough details of a crime to give just punishment. Thus, I see that there is a place for remedial punishment and some protective punishment, karmic punishment should be left to God. Only God knows what punishment is truly just and will give what is just to all.