Well... while this clearly didnt work on you... It may have for others. I can easily imagine someone who is on their own for the first time suddenly realizing they don't really know how to make new friends or talk to people. Someone shouts something positive at them, they respond and start a conversation, and from there a friendship might start.
Is it going to happen every time? Nope. But lots of people are not going to initiate an interaction, even if they are lonely. If someone else does, though, they will engage.
I'm saying this as someone who has pretty bad social anxiety, doesnt really like talking to strangers, and someone who has pretty bad depression.