We cause ourselves pain when we compare ourselves to others. So why do we keep doing it? Because all animals compare themselves to others, and we've inherited the brain that creates this impulse.
People compare themseves to others even though it feels bad. Your brain skims past the good in your life and finds ways that you come up short. We have inherited this social radar from earlier mammals ...