Homelessness only partially overlaps with what British authorities euphemistically refer to as "street lifestyles". The people you see blacked out in the gutter or ranting wildly on a subway car are disproportionately likely to be homeless, but their behaviour is not the result of homelessness - many of them do in fact have a stable home and most of the rest would continue to behave in an antisocial manner even if they were adequately housed.
The problem of persistent disorderly conduct by a small minority of highly disturbed people is either an unfathomably complex psychiatric issue, or a fairly straightforward carceral issue.
you can't possibly know that, in the world we live in. Not conclusively - the amount of other factors at play and the ubiquity of those factors - crushing social stratification, pay-to-live capitalism, the overwhelming pressure on people to produce or die (meaning that learning to produce is on them to figure out, and quick, or else.) If you had an example of a society where these things were not at issue, you could more easily make a statement like "their conduct is an unfathomably complex psychiatric issue or otherwise they just need to be punished enough".
It's quite possible that these people would have turned out fine if they grew up provided a path to integrating into society that was less burdensome. It's possible you're right, too, but without controlling for confounding factors there's no way to know.
Should it be illegal to pass out in a gutter? If so, why specifically?