Our bodies are designed to make us feel bigger than life at the sign of threat or provocation. The area of the brain called the amygdala mediates anger experiences, judging events as either aversive or rewarding. Things that affect our bodily state can make us more emotionally reactive. The would-be attacker fled. In this case, anger helped in the instance of physical attack.
Anger can also be beneficial when one's boundaries are violated.
If someone is pushing you to the limit, there must come a point in which you can assert yourself. Without such assertion, others will begin to make excessive demands on you. People that follow that pattern and constantly give into others' demands are told that they need to be more assertive. Anger fosters this self assertion and it helps us display that assertion. So it appears that we are faced with choosing between two evils.