Ah, good question. Have you ever watched Star Trek? On Star Trek there's something called a "red alert". When a senior bridge officer recognizes that there's danger, he or she calls for a "red alert" in order to automatically launch a series of computer commands like arm weapons, activate shields, call personnel to battle stations. The alert even can deactivate things that might interfere with the functionality of the ship during a battle.
As humans evolved from lower forms of life, we developed more and more complex behavioral functions. Certain situations/stimuli trigger different functions. If I'm attacked by a predator, I go into fight or flight. In order to utilize these effectively, though, we need the right combinations to activate at the right times. Fight or flight alone isn't enough to really do the job of defending me from danger, it has to be joined with a slew of other functions in order to be utilized most efficiently and I even have to have some functions temporarily disabled. If I've had a long day, and my body wants to sleep, the "danger/fear" emotional state overrides my sleep commands. Suddenly, a red alert is called and you go into fight or flight, adrenaline is released to increase blood flow, hairs stand up (that one's not as important as it once was when we were more hairy), etc. All of these things together are a part of an emotional response. Emotions essentially coordinate various functions.
Think about the troubles a pre-civilization human might have faced: defense against physical attack, falling in love for effective mating, experiencing a drop in social status, dealing with birth of a new generation or death of an old one, and even confronting an unfaithful mate all have serious evolutionary functions and would require coordinations of many, many functions. The humans that had these behaviors more than others were able to survive better, and thus emotions became a survival trait.
You can read more about it
here.