> as opposed to just punish and ruin people lives for their mistakes for the sake of making random commenters on internet feel good
That is a strawman.
Besides (potentially) rehabilitation, prison serves to protect the populace from dangerous people who would harm others and as a deterrent to others who can see what punishment they might get if they do something illegal.
I am not claiming prison does a good job of these things, just that its goal is not to "ruin people's lives".