As the earlier poster said, half of the point of prison is that it keeps people out of the general public and thereby temporarily unable to commit crimes against them. Now, we'd certainly like to reform them in prison, but the idea that we can simply, e.g., lift everyone out of poverty and eliminate crime is unrealistic. Certainly, it might remove some portion of crime, but it's not going to stop, say, the serial killers who are primarily motivated by sexual gratification.
Dahmer, for example, killed because it gave him a sexual high and he didn't like having anal sex performed on him, so his gay boyfriends didn't work out and he sought to create a zombie who would never leave him via a crude lobotomy technique. I suppose there's some argument that even he reformed in prison--he converted to Christianity and later helped those studying serial killers--but I wonder how many people would have been willing to let him move in next door to test the extent of his reformation had he not died in prison?
None of this is to say that prison is good or even desirable. One of the worst things it has done is to create a culture for criminals and criminal gangs and thereby facilitate the growth of criminal organizations.
I don't have any grand solutions to any of this, unfortunately, but neither do I believe some of those offered by others.