Society has an obligation to nobody. Governments are only obligated to serve the taxpayers that fund them.
Imprisoning homeless people is not an acceptable solution, because imprisonment costs taxpayer money.
A better solution is to let the market work. If you can't afford the rent for a city, you shouldn't be allowed to be in that city at all, even in a prison cell. People who can't afford to live in an inhabited area should be permitted to camp in the wilderness.