Is there a (evolutionary) purpose of self-pity? I stumbled across the quote from Charlie Munger;


  Generally speaking, envy, resentment, revenge and self-pity are disastrous modes of thought, self-pity gets pretty close to paranoia, and paranoia is one of the very hardest things to reverse, you do not want to drift into self-pity.


And while there seems to be a basic agreement that emotions in general have an evolutionary advantage to "anticipate and solve problems and avoid potential pitfalls", I was wondering which positive effects the "disastrous modes of thought" might have.

The discussion on envy clearly shows that there is a envy-spectrum. And certain modes of envy do contain a positive effect.

And while revenge might not lead to peace and harmony I understand its connection from a the evolutionary point of view.

But what purpose does self-pity have?
Why do we feel it?
Short answer
Self-pity may not have any evolutionary benefit, but may instead be part of the social capabilities allowing to feel empathy. Empathy in turn is a crucial component in social interactions. The development of strong social skills in early Hominids is believed to have paved the way for evolution of Homo sapiens, arguably the most successful species to roam the world today.    

Background
For a trait to be evolutionary beneficial, it should increase reproductive success. Indeed, self-pity may not have a lot of benefit in that regard, especially when depressive thoughts arise. Note that Mr. Munger, who claims that self-pity is disastrous and paranoid, is a business man and may associate such feelings more from the impact it can have on productive human capabilities rather than re-productive ones. 

However, self-pity may be a[n unwanted] side-effect of being able to feel compassion, i.e., the feeling of distress in connection with another person's suffering. In general, self-pity may be the collateral result of being able to allow man to feel empathy, i.e., the experience of understanding another person's condition from their perspective.

The thing is, being a parent, that kids do not feel a lot of empathy. Especially young kids (&lt;2 years) lack the empathy we see in most adults (barred those with e.g. autism spectrum disorder). Kids do, however, feel a lot of self-pity :) Self-pity seems to be an inborn, relatively unsophisticated emotion. Later, when they grow up, they will develop these egocentric feelings into empathy, by projecting their own emotion (self-pity) onto other people (feeling sorry for someone else). These emotions have to be developed and nurtured through social interactions. Admittedly, I am not a psychologist or evolutionary biologist, but I do reckon that feelings of self-pity are a precursor for feelings of sympathy and compassion and, on a grander scale, for feelings of empathy.

Empathy is believed to be a critical factor in enabling humans and other primates to socially interact with each other (De Waal, 2012). In turn, the social behavior in humans is considered to have been a crucial trait that lead to the success of the human species (Byrne &amp; Whiten, 1989). Social interactions likely helped our ancestors to form social groups, such as extended families and coalitions that promote higher rates of survival and reproduction. Enhanced social structures allowed for the sharing of knowledge across generations. The increasing size of such social groups in turn entailed further social brain development, ultimately giving rise to the present form of the highly social brain of humans (source: Huffington Post). Frans de Waal has written extensively about the mechanisms and benefits of empathy in primates.

References
- Machiavellian Intelligence, Oxford Science Publications (1989)
- De Waal, Science (2012); 336(6083): 874-6