The fight-or-flight response is a physiological reaction that occurs in response to a perceived harmful event, attack, or threat to survival.
It was first described by Walter Bradford Cannon. His theory states that animals react to threats with a general discharge of the sympathetic nervous system, priming the animal for fighting or fleeing.
An evolutionary psychology explanation is that early animals had to react to threatening stimuli quickly and did not have time to psychologically and physically prepare themselves.
The fight or flight response provided them with the mechanisms to rapidly respond to threats against survival.