Being in pain is a way of perceiving something as bad. Pain has an intentional object, namely the bad. In being made miserable by the causal consequences of one's evil action, i.e., by the punishment inflicted on one, one has the opportunity to see that action as bad—the suffering from the punishment supplies a quale to one's perception of the action. But to see the action as bad is a good thing, since the action is indeed bad. Hence, it is non-instrumentally good for one to be punished.