It is not unusual for homeless people in the US to commit crimes so
they can sleep in jail.
Homeless shelters are very uncomfortable places, and have painful rules,
such as that you must go out and spend your day on the street. I expect that
you are forced to sleep in a small room with several strangers.
Per inmate, a prison is far more expensive than a shelter. I expect
that even a comfortable shelter with all the advantages of a jail,
giving a person a small room to call per own and lock behind per when
going out, would be much cheaper to build and run than a prison.
Sadism is what gets in the way. The US is unwilling to spend money on
helping the homeless, but it pays millions for prisons.