While it's not true, as many people believe, that crime is on the rise, there's some reason to think that prison as a deterrent is less effective than it used to be. And this is really not surprising when you think about it.
Why would you not want to go to prison? You could no doubt rattle off reasons, and what are the worst of those reasons would depend on the historical period in which you were making the list. Hundreds of years ago, the rapid spread of disease through prisons would have been high on the list, but nowadays, prisons are nowhere near as unsanitary as they used to be. We still have a lot of prisoner-on-prisoner violence, including rape, murder, and brutality, and there's still guard-on-prisoner abuses as well, but these are things we rightly consider unwanted and in need of correction. There are still indignities, humiliations (beyond the basic humiliation of being convicted and imprisoned, I mean), and emotional agonies.
But the most fundamental downside of prison is the loss of freedom. You can't go where you want to go, do what you want to do, eat what you want to eat, see who you want to see. We may have slightly softened this with some choices about food, activities, visits, etc. (mostly in the name of rehabilitation), but ultimately, prison is about the loss of freedom. That is the downside that is the intended form of deterrence.
All the others are side effects, and in most cases, ones that we should be trying to eliminate, because the loss of freedom should be enough. If you were sent to prison and had no worry whatsoever that you would be raped or brutalized, you should still hate the idea of going to prison.
So why isn't that enough of a deterrent? Because for most of history many of the people who might be going to prison would be leaving a life that is worse than a loss of freedom. They might have little freedom anyway. But they also have far worse things to contend with, like danger, starvation, crime, and abuse. Compared to those things, a safe warm place with free meals might not be that bad.
And as time passes, the gulf between the rich and poor grows greater. I'm not saying that the poor are getting poorer, or lower qualities of life; that's another common misconception. But their lives are worse now than in the past when measured relative to the ambitions they might realistically have. Which makes the comparison to prison change.
Historically, prison has been worse than the lives that potential criminals might face, not because of the intended awfulness of loss of freedom, but also because of all those others which we just hadn't fixed. Some people will probably object to fixing those problems because they want prison to stay awful; they say we're "coddling" prisoners and turning the prisons into resorts. Confront them with specific abuses like prisoner rape and only the most stubborn will defend the particular practice, but they'll still want to support the idea that in some vague way (that they don't have to face), prison remains awful as it always was.
But that's backwards. We can't turn a blind eye to brutality and indignity in our prisons just to ensure that prison remains worse than the alternative, just as we shouldn't have, and eventually didn't, turn a blind eye to bad health that caused rampant disease in prisons. Instead, we should be correcting the inhumane treatment of people, both in prisons and outside prisons. When life on the streets is not a grinding dangerous abyss, then prisons won't have to be an even worse heap of brutality and indignity to remain a suitable deterrent. But it's ironically easier to address inhumane conditions in a prison than on the streets: prisons are controlled environments run by people who have accountability, but the problems on the streets are much bigger, more nebulous, harder to change, and harder to pin on any particular person or group to fix.