I think the fundamental statement is that, "Society teaches you that some acts are forbidden." The concept of "forbidden" entails negative consequences. More generally, I think you're analyzing a social phenomenon at an individual scale, which is needlessly confusing things.
Let me make three assumptions. I don't think there are any societies that would contest them, though of course nihilists, egoists, and other special philosophies exist.
Given that all of these are true, there are bound to be forbidden acts. Something is not forbidden where a rational actor prefers all of the consequences of doing over consequences of not doing it (i.e. assuming a 100% chance of being caught). For example, if the legal consequences of thievery were that you were given a large wad of cash so you wouldn't need to steal, this would not really amount to forbidding theft, and indeed it would encourage it to occur. Also, that wad of cash had to come from somewhere, and thus you've diverted resources from some other entity.
The concept of forbidding something requires it to have unpleasant consequences. (This is excepting fantastic situations like omniscient police.) That doesn't mean that your happiness has strictly negative value - we don't torture prisoners - but it does mean that some unhappiness must be inflicted on some individuals that happiness generally can be maximized.
It might be nice if we could get all the results we want without having to make people suffer, but reality just doesn't work like that. Understanding crime and punishment from a utilitarian perspective is really no different than understanding going to the dentist from a utilitarian perspective. It's unpleasant, and if we could get the same results without doing it, we would, but we can't, and it's much better than the alternative.
I think this practical necessity has then shaped most people's concept of morality. It's really good for society if we punish murderers, therefore, it's really good to punish this murderer. Carrying out just punishment does increase utility (there are interesting prisoner's dilemma parallels here) in the aggregate in the long run, and thus we assign positive moral value to it.
I'm curious as to an alternative approach. What would you do with thieves, murderers, and rapists, that can actually be done with existing technology?
Punishment doesn't seem like a very reliable way of getting people to not do what you don't want, but I'm not sure that an absolutely no-punishment society is feasible.
Why do those words go together?
Society - and for once, I'm using this term universally - teaches that, if you committed a crime, you should be punished.
But in some societies, we have an insanity defense. If you had a brain condition so that you had no - here it's a little vague - consciousness, or moral sense, or free will, or, well, something - then it would be cruel to punish you for your crime. Instead of going to prison, you should be placed somewhere where you can't hurt anybody, where professional physicians and counselors can study your case and try to reform you so that you can rejoin society.
Wait - so that isn't what prison is for?
No. Prison is to punish people. Is it any wonder that prison doesn't reform people, when we don't want it to reform them? Most people would be upset if prisoners could go in on Friday, and emerge, rehabilitated, on Sunday. When people say, "It would be cruel to punish people who aren't responsible for their actions", they are implicitly saying, "Prison is necessarily cruel; and that's good, because we should be cruel to criminals who are responsible for their actions."
But the more we learn about psychology and neuroscience, the further responsibility recedes into the distance.
Outcome-based justice argues that we should give up playing the blame game, because neuroscience keeps finding more and more proofs that things are "not our fault". Instead, we should write laws that deter crime.
You might think this is what we already try to do. But it isn't! Witness this confused article from the Brookings Institute, Cognitive Neuroscience and the Future of Punishment by O. Carter Snead. Snead objects to outcome-based justice. He summarized all of the arguments for it, yet managed to completely miss their point, concluding where he started from, saying that outcome-based justice is obviously bad because it could lead to being cruel to people who didn't deserve it. (Instead of only being cruel to the people who do deserve it, which is obviously what we want to do.)
Snead understands that outcome-based justice deters crime:
You might expect that Snead goes on to explain why these laws are bad things. But he doesn't! He assumes we can all see that these are obviously bad things.
The Wrath of Kahneman describes a study which asked whether people punish others in order to deter crime, and concluded, No. People are doing something else.
One theory is that people are trying to be fair. Everyone should get the same chances; everyone should get the same punishment for the same crime. John Rawls argues this explicitly in Justice as Fairness: Justice should not be utilitarian, but should instead be fair.
I believe Rawls' view is also the popular view of what "justice" means. And, I will argue in a later post, it is part of a pattern showing a deep divide between two different ways of using the word "ethics".
ADDED: Constant made the point that, while one part of outcome-based justice is preventing future harm from the criminal on the dock, another part is deterring harm by other criminals. This latter part does not benefit from punishing criminals who cannot be deterred. Thus, to optimally punish both criminals who can and cannot be deterred, the law requires a concept of moral culpability, and should punish criminals who can't be deterred more lightly. This is a better origin story for the linking together of morality and free will than the just-so story I'd come up with, so I plan on stealing it for my next post. (SilasBarta may have been trying to make the same point, but I found his comments impenetrable.)
(This post is laying groundwork for two other posts that will go in different directions, neither of which concerns justice.)