I don't think punishment is evil at all so I don't suffer this conundrum, we use both condemnation and praise to shape society, we as a collective praise the actions we deem to be good and condemn those that don't, where reward and accolade are the high end of praise, punishment is the high end of condemnation - this is the foundation for moral judgement, as such it cannot be judged in terms of morality because in order to judge punishment as being immoral, you need to use condemnation, and punishment is a form of condemnation.
.