First of all, maybe in Berlin. There are a few reasons for people living in the streets. Drugs is a big one, especially in Berlin. You won‘t find that in most of Germany.
Fact is, most people who are legally in Germany for >3 months are legible for Hartz 4: a free apartment, free heating and a few hundred Euro. And free healthcare.