It's not just the deterrence but to publicly condemn the act. Condemnation needs to have teeth and the perpetrator needs to feel the burden, otherwise it's just empty words on paper. The burden is necessary to establish social balance. The punishment can't be enjoyable, it needs to take away the unfair advantage gained by the criminal act, it provides a way to repay moral debt back to society.
> A fourth feature of punishment, widely acknowledged at least since the publication of Joel Feinberg’s seminal 1965 article “The Expressive Function of Punishment” is that it serves to express condemnation, or censure, of the offender for her offense. As Feinberg discusses, it is this condemning element that distinguishes punishment from what he calls “nonpunitive penalties” such as parking tickets, demotions, flunkings, and so forth. (Feinberg, 1965: 398-401).