Everything that God does, he does for the sake of some good. But to be a good is to be a good
for one or more entities. Thus, everything that God does, he does for the sake of some good for one or more entities.
One of the things God does is retributively punish some sinners. This is controversial, but I think true, and I shall assume it. If you don't buy it, then take the following to be an exploration of what would have to be true if God were to punish retributively.
It follows that he does this for the sake of some good for one or more entities that I will call the
intended beneficiaries of the punishment.
God cannot be the only intended beneficiary. For God is transcendent. His intrinsic well-being is not affected by what happens in the creaturely realm. If God is a beneficiary of the retributive punishment, it is only in the derivative sense in which anything that benefits someone one loves counts as benefiting oneself.
What are the remaining options for the intended beneficiary? I think the only plausible ones are: the sinners themselves, the victims of the sin, and bystanders.
But the sin need have no victim beside the sinner. It could, for instance, be a sin of blasphemy against God (and while the sin is
against God, God is not
victimized). And God is not the only intended beneficiary. So the victims of the sin cannot be the only beneficiaries.
How about bystanders? Tertullian suggested that the saints in heaven will rejoice at the suffering of the wicked. But a virtuous person rejoices only at something that is good for reasons independent of the rejoicing. Hence the primary good of the punishment of the wicked cannot be that it enables rejoicing by the righteous. Moreover, it would surely be possible for God to punish someone without there being any bystanders--for instance, God could have chosen to create only one person, and if this person sinned, God could have punished this person.
That leaves the sinner.
Of course, sometimes punishment benefits the person being punished by leading her to repentance. But if that was the only good being pursued by God in punishing the sinner, then that would not be a case of
retributive punishment.
I think the only remaining option is that retributive punishment is simply good in and of itself for the person receiving it. It is good for one to get what one deserves, be it punishment or reward. Think of the case of reward. If you have done something good, and I reward you for it by giving you a gift, the value of the reward for you is not just the value of the item that I've given you--it is the value of the item
as a reward from me for your good deeds. Likewise, if you have done something wicked, and I have the authority to punish you for it by imposing harsh treatment on you, while the harsh treatment
as mere harsh treatment has a disvalue, the fact that it is harsh treatment given
as a punishment from me for your wicked deeds has a value, and it is a value for you (it's surely not a value for me, nor necessarily for the victims or bystanders).
Of course it is possible to receive something of value without appreciating its value. The repentant sinner appreciates the value of justly deserved harsh treatment--that is, in fact, one of the signs of a criminal's repentance--but the unrepentant sinner does not appreciate it. But it has a value, nonetheless. If it didn't, it wouldn't be a sign of vice that one does not appreciate it.