The vast majority of homeless people suffer from mental illness, and have come from broken homes - experienced severe childhood trauma.
These are people who, mostly, never had a chance. This is the key point. They were dealt a truly garbage hand in life, and no amount of 'pull yourself up by your bootstraps' is going to change that.
They need care, they need education, they need homes. They need people to invest years of work into their rehabilitation.
And, in pretty much any developed country, providing that is roughly equivalent in cost to what we currently spend punishing them.
The state is paying the cost of homelessness, but it is doing so in a fashion that both fails to solve the problem and makes the quality of life for these people even worse.