Rah, rah, rah! Bravo... But you're demonstrably wrong. Prisons
do nothing for prisoners other than make them better criminals.
What they do is make the community feel better. The primary role
of the legal and court system is "to reflect community values".
Thus "justice must be see to be done" and be "fair"; that is, seem
fair to the community (this is generally how archaic laws stop
being enforced; a judge declares that the community values have
changed and there should be no or nominal punishment. Less commonly
are they actually repealed).
Since putting people in prison is an immediate, visible and quick
fix, its very popular (public outcry get people kept in prison
longer, or released earlier). Actually trying to reduce or prevent
crime is a more complex and subtle process which is less often
explored, despite being ultimately cheaper (generally).
This posting is not irrelevent to the current debate.