"Make people not do bad things" is a golden goose. Nobody has yet come up with a way to make that actually happen.
Until someone does, the next best thing is to remove people that do bad things from society so that it can continue to function.
Commonly this involves isolation from society (imprisonment) which also serves as positive punishment. Some call for further punishment such as public floggings or total removal from society by execution of course which in my PERSONAL opinion is going too far. Of course there will be people howling for vengeance, which is a bad motive, but don't let that blind you from the valid reasons for punishment.
While you're sitting dreaming of ways to stop people from doing bad things would you rather there were no penalty for crime, or have I myself now misrepresented your views?