Look at El Salvador. They locked up a sizable portion of their population in a short time and put them to work. They more than cover the costs of their incarceration. As their president says, they are helping to rebuild the nation they destroyed.
Also, their prisons are not a pleasant place, even for people who are used to living in slum conditions.
Prison doesn't rehabilitate, it just produces a financial drain on society.
I am pretty sure those prisoners in El Salvador are not putting into the economy what it takes to build, staff, and maintain the prison. Then add the costs of food and hygiene items needed to house people in mass. Not to mention the medical care of them fucking and stabbing each other.
Of course prison isn't a pleasant place. This is why the average White man is deterred.