The short answer
Social comparison theory is the foundational psychological idea that people evaluate their own abilities and opinions by comparing themselves to other people, especially when there's no objective yardstick available. It was formally proposed by psychologist Leon Festinger, who argued that this drive to self-evaluate through comparison is a basic, largely automatic feature of how people function, not an optional habit some people have and others don't.
The research
Social comparison theory proposes that people evaluate their own opinions and abilities by comparing themselves to others specifically when an objective standard for that evaluation doesn't exist — which describes most judgments about how well a life, career, or relationship is going.
— Festinger, L., "A Theory of Social Comparison Processes," Human Relations, 1954
Why comparison happens at all
Festinger's original theory proposed that when an objective standard exists — a ruler, a test score, a clock — people use it directly and don't need to compare themselves to anyone. It's specifically in the absence of that objective standard — "am I doing well at life," "is my career on track," "is my relationship normal" — that people default to comparing themselves against other people instead, usually people they see as similar to themselves.
Upward vs. downward comparison
Later research built on Festinger's original theory by distinguishing upward comparisons (against someone perceived as doing better) from downward comparisons (against someone perceived as doing worse). Upward comparisons are more likely to be motivating in small doses but are also more consistently linked to feeling worse about yourself, while downward comparisons tend to boost mood but rarely produce lasting motivation — which is part of why an upward comparison can feel productive and corrosive at the same time.
Why it matters for feeling behind in life
Almost nothing about "how your life is going" has an objective yardstick — there's no universal scorecard for career progress, relationship timing, or financial stability. That absence of an objective standard is exactly the condition Festinger's theory predicts will trigger heavy reliance on comparison to other people, which is a large part of why life-stage comparison feels so constant and so hard to simply decide to stop doing.