I was street homeless for a while, and knew (and still know, very well) most of the homeless people in the large city where I lived. The fact that I didn't drink, smoke or use drugs was a major talking point among the other homeless folk I knew, so unusual was it.
In my experience 99% of street homeless are addicted to drink or drugs or both. In almost all cases, they aren't abusing substances because they're homeless, they're homeless because they're absuing substances. They will almost always deny having substance abuse issues but are almost always begging solely to feed their habit. The homeless are NOT required to pay for a bed at a night shelter and most homeless are given (by passers by) more food than they could possibly eat - all of their money goes on feeding their habit. It doesn't do anyone any help to delude ourselves that most homeless people aren't on drugs or that if they are, they only do so because they're homeless, because that really is not the case.
It is generally not actually hard to get off the streets. Homeless charities are very good at getting people into supported accommodation very quickly, as happened with me. If you're genuinely just down on your luck and just need a helping hand getting a roof back over your head and helping you sort out benefits or get back into work, this is fairly easy to do. A lot of 'homeless' you see begging are not actually street homeless and in fact do have accommodation.
What they find hard is sustaining that accommodation. Most homeless people I know have been housed multiple times and lost that accomodation each time due to rent arrears or anti-social behaviour stemming from their substance abuse issues. Even many of those who sleep on the streets have accommodation but don't utilise it because the time and money spent travelling to and from it is time and money which could instead be used to fund their habit.
Rehab alone is rarely successful because the user immediately returns to the same social circle etc. and inevitably relapses. Many had poor childhoods and never had a 'normal' life to begin with so lack the life skills neccessary to build a life away from substance abuse. What does have a better success rate is long term residebtial rehab where the user not only detoxes from drink or drugs but is also given therapy to deal with the underlying issues and is taught the skills they need to function in society. They go through several stages of rehab, increasing their level of independence and decreasing their need for support, and by the time they leave rehab have accommodation, a work placement and the life skills they need to make a go of it. That sort of rehab is vastly more successful than short term rehab or detox.
If you really want to help homeless people, campaign for more funding and access for more long term residential rehabs, and for more effective support for troubled families and kids in care in the first place so they don't grow up with the issues which often result in them spiralling into addiction and homelessness.
What does nothing to help is to delude yourself that
-homeless people aren't on drugs
-they're only on drugs because they're homeless
-your money will be spent on food or shelter
-a roof over their head will solve their problems