This doesn’t even have anything to do with homeless people. Homeless people don’t sleep on a window sill.
I personally know a few places in my city where people have resorted to putting spikes on their window sills like that. It has everything to do with anti-social people who think someone else’s window sill is a perfectly good place to sit around all night, make noise, drink alcohol, do drugs, leave their garbage, damage the property, …
The spikes are put there out of desperation when talking to people and talking to the police hasn’t helped.