Negative emotions are fundamentally indicators of a cognitive dissonance and are absolutely invaluable in maintaining a healthy system of introspection. Your profile shows you're also a programmer so here's an analogy I use internally: negative emotions are part of a monitoring system built into our brains that inform us when an assumption in our set of operating beliefs (our personality source code) has been violated. (You get angry when your beliefs about 'fairness' are violated, you feel disappointment when your beliefs about e.g. 'relationships' are violated, etc.)
Positive emotions fulfil a similar role, in the opposite direction by reinforcing the value of the beliefs you've created, although negative emotions are more interesting because your response to the emotion can be extrospective ("I feel angry because that guy cut me off on the road and that violates my beliefs about fairness; I'm getting out my tire iron and teaching him the right way to do things") or they can be introspectively rational, controlled and empowering ("Should I revisit my beliefs about fairness to be more in tune with reality, where people make mistakes?"). People with dysfunctional belief systems and rigid attitudes towards their beliefs are prone to depression (i.e. their belief systems do not serve them well given reality, either through distortion or inadapation).
From an evolutionary perspective, I suspect extrospective analysis was more useful ("I'm angry because the other ape has stolen my lunch, and resources are scarce, so I'm going to punch him in the face"), which explains our default, instinctive "emotional" response to emotions, but as civilization develops and the rules change, introspective responses (which encourage co-operation) are more useful (but more fraught with dangers such as depression, which is a kind of reinforcement feedback loop of negative emotional states, beliefs and poor assumptions). Nevertheless, the high value of emotions remains present.
If anybody reading this finds this personal philosophy interesting, I highly recommend reading David Burns' "Feeling Good" for an exhaustive listing/discussion of emotional states and responses, and constructive ways of dealing with these experiences.