First I should alert you to a common misconception that envy and jealousy are the same thing, and thus can be used interchangeably. Actually jealousy is the fear of losing something you already have to another. For example, one might be jealous of losing his girlfriend to the good-looking guy across the street. Envy involves the pain and/or frustration of, say, not having the guy across the street's good looks. In the example above, you can see that envy involves two people, and jealousy typically involves three people.
In a very interested study on envy, researchers in Japan looked the at fMRI scans of individuals' brains as they were told to imagine scenarios where they were envious of various people. In it, researchers found that envy elicited brain activity in the dorsal anterior circulate-cortex (dACC), the area responsible for processing both physical and emotional pain. In another interested caveat, researchers also measured levels of schadenfreude, known as the feeling of pleasure at the envied one's misfortune. Again, this is probably not a feeling that most would willingly admit to, especially when it comes to friends, family, etc. However, it appears that the emotion is normal and quite common. When participants of the study imagined the downfall of the envied one, researchers found increased activation in the ventrial straitum which is rich with dopamine. Activation in this area produces a good feeling, meaning that the participants took pleasure in the imagined character's demise.
These feelings come from our tendency to measure our own success against someone elses. This is called social comparison. Social comparison is helpful because it can assist us in striving toward our goals. However it can also lead to anger and frustration at not reaching those goals due to envy. We only compare ourselves to people with comparable skill sets and abilities to our own. I will never be envious of LeBron James' ability to dunk a basketball and LeBron will never be envious of my "vast" knowledge in psychology. However, LeBron could be envious of Kobe Bryant. After all Kobe does have a couple of NBA championships under his belt. Perhaps Kobe is a bit envious of all the attention LeBron receives and takes pleasure in his having an off night. You see envy can only show up if we believe what the other person has is attainable.
So why do we feel envy if it's so destructive? Emotions can have both adaptive and maladaptive components. Negative emotions like anger and fear can compel us to act on a situation that may be harmful to us. Sadness can help us get through a period of morning. Of course we strive to feel positive emotions such as joy and love. Our hedonistic tendencies to approach these positive feelings drive our daily lives. However envy seems less functional given it's often toxic consequences. I encourage everyone to check out Robert Plutchik's (1980) list of basic emotions for more information. In it you'll see that he list eight basic emotions, in that there are secondary and tertiary emotions. Pluchik states that envy is a secondary emotion to anger. In other words a functional emotion can sometimes be followed by a dysfunctional or maladaptive emotion. There is nothing extraordinary about that really, however the envy researchers briefly pointed to a reason why envy may, in fact, be functional.
Like many psychological theories, the researchers' reasoning was born out of evolutionary psychology. They hypothesized that envy could drive animals to vie for the attention of their mothers, allowing them to obtain more food and attention, which would then increase their chances of survival. This certainly makes sense, though it would be difficult, if not impossible to measure. Luckily we've evolved to be much less instinctual and much more thoughtful. Meaning that although we might naturally feel envy, and even feel schadenfreude we can modulate those feelings by using self-control.