1. You force yourself to get out of your comfort zone.
When you talk to people you already know, you're at an advantage because you already have some insider information about the listener. These tidbits of data--for example, that they lean a certain way politically or like oatmeal for breakfast--helps you say the "right" thing in the "right" way. But when you try to compliment or engage a stranger, you have to start without any of that to guide you. You don't know if the response is going to be "thank you", a disconnected grunt or a distrusting look of suspicion. You have to face this uncertainty and be willing to get past initial awkwardness.
2. Thinking on your feet gets easier.
Trying to compliment strangers means that you have to take in information and respond very quickly. For instance, you might have only a few seconds to note what they're wearing, the tone they use talking to their child or that they seem incredibly relaxed when everyone else seems a little tense. As you practice coming up with appropriate questions or comments on the fly to initiate the conversation and keep it going, you'll get better at analyzing and deciding what to do next in other situations, too.
3. Your mindset leans positive over time.
As I've highlighted many times in previous articles, researchers know that dopamine, a chemical that helps you feel happy, gets released in anticipation of reward. While the reward actually doesn't have to be something positive, the takeaway is that the dopamine will keep motivating you to repeat whatever you did or find something new that similarly stimulating. When you have pleasurable interactions with others because you chose to compliment them, you essentially train your brain to keep looking for more of what's positive in others and your environment, literally changing your noodle so it's easier to stay upbeat.