One of the most longstanding principles of functional legal systems is that the law must be capable of being obeyed. (See Lon Fuller's famous book "The Morality of Law" for the canonical discussion.)
When legal rules are literally impossible to obey for some people, they cease acting as legal rules and just become status crimes. If it's illegal to sleep outdoors, then anyone who doesn't have the money to sleep indoors becomes a criminal no matter what they do.
If you're seriously interested in engaging with this question, I've written about it some from pp. 1059 onward of this law review article.[1] Jeremy Waldron, a really important philosopher of law, has also written several articles on the subject, his "Homelessness and the Issue of Freedom" is particularly important.
[1] http://paul-gowder.com/Equal_Law_in_an_Unequal_World.pdf