I think the whole purpose of punishment is to discourage others from committing the same crime - not to punish an individual for the sake of retribution.
If you think about it, retribution is pretty petty. It doesn’t accomplish anything and a civilized society should do away with it.
The only reasonable basis for punishment then is the “educate millions” rationale above. To the extent that it is effective in establishing rails for a stable society, I think it’s morally acceptable to do so.
You accurately summarized the crux of the argument: it’s all about your views on the dignity of the individual.