When humans evolved in small bands of 20 to 100 people, standing within the tribe was vitally important. Your reproductive success, access to resources, and even your children’s future, depended a lot on your popularity.
It’s not surprising, then, that people who experienced a rush of pleasure when they received social validation — a “dopamine hit,” in today’s popular language of neurochemistry — were more likely to survive, leaving a strong evolutionary bias toward people with a desire to receive social approval. (And a fear of social disapproval, which is why speaking in public is one of the greatest phobias.)
Social media companies know this, and take advantage of it. There’s even a company called Dopamine Labs that specializes in making apps more addictive. (And “more addictive” is a fair way of putting it, given that “dopamine hits” in the brain are also a key mechanism for addictions to alcohol, drugs, gambling and the like.)