Your "jail time solution" here has a few flaws. One of the major one's here, you're not considering some of the finer details on homelessness, jail time, and how these kinds of things work.
Firstly, an estimated 30-40% of all homeless people are homeless as a result of substance abuse (which is a general statistic in most "first world countries"), be it drugs or alcohol or both. I imagine a lot of the "sick" people you see on the streets are likely "sickly looking" not because of some underlying medical condition that they desperately want fixed (although that is indeed another one of the "top" reasons why a person may end up homeless, at least here in the US where a minor health problem could put you years in debt

), it's more likely they look that way as a result of years and years of substance abuse. Your solution of jail time already fails at this point: Substance abusers are extremely unlikely to simply decide to "stop abusing" on their own and get clean and better their lives. They often have the mentality of "Why should I give up my precious, precious drug fix for something dumb like a roof, or a bed?! Those things don't make me feel as good as alcohericraPCP and I already have this cardboard house and a couple blankets!".
Then you have to consider whether jail time is actually an improvement vs general homelessness. When you're homeless, you still have freedom to do what you want, when you want, where you want. Sure, you might sleep under a stack of cardboard or something and have to beg people for basic sustenance, but a lot of people consider that better than facing jail time. When you're in jail, you'll face discrimination/abuse (from virtually everyone), violence, drug abuse, sexual abuse, etc etc. You also vastly overestimate the healthcare system in prisons. Half the time, if you have a general mental condition that was the cause of (or result of) your homelessness, you won't be receiving the kind of care you need to live a stable lifestyle. If anything, prison time is more likely to be
worse for someone with a mental condition than simply living on the street.
Then you have to consider what a "minor crime" sentence actually looks like. Your example of shoplifting, for example, most often results in a fine rather than substantial jail time depending on the value of items stolen. And seeing how the average homeless person isn't exactly going to be a mastermind thief capable of stealing thousands of dollars worth of items, this would then require a more serious crime to be committed in order to get a substantial enough sentence to put you in a "better place".
There's also the additional problems jail time will have for someone who's homeless. As soon as you commit that crime, acquire a record of any kind, and "do your time", your chance of viable employment decreases drastically. Businesses that hire people with criminal records are often minimum wage, require skills that a homeless person may not have, or might lose during their prison sentence, and generally aren't stable enough for someone who's homeless to deal with.
And then you just straight up ignored the fact that those services that cater to prior criminals regarding a "better lifestyle" also generally apply for the homeless as well. Why would you commit a crime, lose basic freedoms and months/years of your life, drastically reduce your chance of employment, and waste tax payer money when you could've just, y'know, hopped on over to an unemployment office and find a way out instead? Or head to a local public library to get your fill of "education"? Or go to the many homeless shelters available for a roof over your head? Or look for help from the hundreds and thousands of charity organizations that were specifically created to help the homeless "get out"?
tl;dr going to prison if you're homeless is the opposite of a solution.