The human response to unfairness evolved in order to support long-term cooperation(1):
This sense of fairness is the basis of lots of things in human society, from wage discrimination to international politics (…) What we’re interested in is why humans aren’t happy with what we have, even if it’s good enough, if someone else has more. What we hypothesize is that this matters because evolution is relative. If you are cooperating with someone who takes more of the benefits accrued, they will do better than you, at your expense. (Sarah Brosnan as quoted by Phys.org in “Human sense of fairness evolved to favor long-term cooperation”)
Human sense of fairness is a puzzle for economists. They don’t understand why, for example, pretty much everyone thinks that CEOs get paid too much(2). Sarah Brosnan and Frans de Waal find that humans and other species seem to share basic reactions to inequity, which serve the need for sustained cooperation:
The hallmark of the human sense of fairness is the idea of impartiality; that is, human fairness or justice is based on the idea of appropriate outcomes applied to everyone within the community, not just a few individuals, and, in particular, not just oneself. Thus, outcomes are judged against a standard, or an ideal. There is variation in this ideal across cultures or situations, but there is consistency within a given context.
Fairness is not for the faint of heart. Individuals must have emotional control to forego short-term positive outcomes in order to gain long-term ones. Only after 7 years of age do children resist the temptation of rewards and begin to refuse low offers for strategic reasons.
You can read more about fairness here.
(1) Sarah F. Brosnan, Frans B. M. de Waal, “Evolution of responses to (un)fairness”, Science DOI: 10.1126/science.1251776
(2) Sorapop Kiatpongsan and Michael I. Norton “How Much (More) Should CEOs Make? A Universal Desire for More Equal Pay”, In Press, Perspectives on Psychological Science