Prisons weren't created to rehabilitate people. Really, it's simple economics.
Just like in the economy, in the legal realm there are behaviors you want to encourage and behaviors you do not want to encourage. Economically, you want to encourage free trade to increase competitiveness, so you eliminate tariffs. You don't want corporate shareholders to save all of their profits, so you give them tax breaks when they invest money into improving production.
Legally, you don't want people to behave outside of the law. In order to deter them from doing so, you create costs (punishments) that are large enough to make them wary of doing so. Prison, taking time from your life and removing the freedom to live within your desired conditions, is that cost. If we make prison life too "humane" and like everyday life for law-abiding citizens, it removes the deterrence factor.
Prisons were created for deterrence and the obvious reason of quarantining the bad guys in society, but operate as places of rehabilitation as well. I'm pretty sure most prisons in America have programs that deal with rehabilitation. There's a reason they ask you if you feel rehabilitated when you ask for parole. The long-term ideal goal of prison is rehabilitation.
That's why people living in poor conditions are more likely to commit crimes--they have less to lose by going to prison than someone with a nice house in an upscale neighborhood.
And then you have Enron.