I am not an expert so don't take me too seriously, but I have an idea about this. When you commit a crime you incur a debt that you owe to God because of this crime and it has to be paid back to God in this life or in purgatory or in hell. For those who commit crimes worthy of the death penalty, if they accept their punishment willingly and come to believe in God, when they are put to death (of course after confession, extreme unction, and communion) they can pay off their debt owed to God by their death and spend less time in purgatory and maybe even avoid purgatory and go straight to heaven.
That is just a thought though, so I may be wrong. I did not go look up the answer from a good Catholic source.