This is just my personal, humble take on things, but I tend to see humans as not necessarily inherently good, nor evil; rather, I see them as full of great potential. There is indeed effort that many need to undertake in order to be "good," as there are many temptations inherent in what could be construed as "bad," but this effort varies from person to person for a myriad of reasons. Some of those reasons are outside one's control, some are due to a conscious effort to be good, to the degree that it becomes part of who you are. Doing someone harm becomes such a core part of yourself that you are repulsed by even the very idea.
I think, punishments such as these, stem from society's (albeit poor) attempts to keep people in line, to keep them "good." Many aspects of religion, for instance, follow along this vein. The concept of heaven and hell, for instance, is based on these behaviors, and growing up surrounded by heavily religious people, I have heard many say you shouldn't do something, simply because you would be sent to hell for doing so. Not that it's necessarily wrong to do so because of the pain it would inflict on others, but because of simple reward/punishment dynamics. "Oh crap. I shouldn't do that. I'd be sent to hell." Which is very much so in line with "Oh crap. I shouldn't do that. I'd be sent to prison." Executions, prison, and even these beliefs, end up seeming like methods of control. However, they do not teach the right things. Compassion, for instance. "Oh crap. I shouldn't do that. It would hurt someone. I know what that pain feels like. Why would I want to inflict such a thing onto someone else, knowing how much it hurts?" I know that there are extreme circumstances in which individuals legitimately are beyond reasoning, in which they would cause pain no matter how much you attempted to teach them the merits of things such as compassion, however... there are many, many, instances, in which we defer to these simplistic, harmful methods, out of the convenience of using them to keep control. Let fear and pain do the work.
I fear I am ranting, so I shall stop now... these are simply things I think about. Prison, quite often. The effects of it upon those who are kept within such inhumane walls. Those who leave worse than they entered. Those who die within the walls worse than they entered. Those who are killed who did not need to be killed. All the lives that could have been saved by focusing our efforts on saving lives, rather than taking them. There is so much potential there - for good, for bad, for everything inbetween. Often it pains me, how much of that potential is lost.