Ibn Hazm says:
26. “Never lose your temper,” as Allâh’s Prophet (peace be upon him) said to a man asking advice, and, as he also said commanding him, “Do as you would be done by”, together encapsulate the whole of virtue. Indeed, the fact that the Prophet forbade all anger implies that although the soul has been given the ability to be angry, it should refrain from this passion, and the [Prophet’s] commandment to do as you would be done implies that the souls should turn away from the strong force of greed and lust and should uphold the authority or the means of justice which springs from the rationality which is part of the reasonable soul.
Notes:
* Generally speaking, anger is an emotion through which greed, lust, and injustice is usually carried. Rarely do you find a man oppressing others, and himself, except that he is in a state of anger - save of course, those who are maliciously evil (think: world 'leaders' who plot and plan the deaths of thousands through war for selfish gain).
* This said, anger is not necessarily totally prohibited. In fact, the Prophet himself would be angry at certain times, and almost all of these instances were recorded, since it was not in the Prophet's customary disposition to be angry. Rather he, upon him be peace, was known to be cheerful, and would constantly smile. So when he did get angry, the companions would always know, and take record of it. Therefore you'll come across some narrations stating "we found the Prophet angry" or "his face turned red from anger".
* There is something interesting, in fact great, in the anger of the Prophet. It was never for his own selfish sake. Hind (ra) says: "No one would stand against his anger when matters of the Lord’s truth were opposed, until he had triumphed, but he would never get angry for his own sake, nor would he ever seek to win such an argument."
Aisha (ra) also narrates a hadith in which she states: "Allah's Apostle never took revenge (over anybody) for his own sake but (he did) only when Allah's Legal Bindings were outraged in which case he would take revenge for Allah's Sake."
* His anger was never for his own sake. It was not due to people harming or annoying him. Ibn Hazm's words apply to this type of anger. An anger of selfishness. Rather the Prophet only let himself (i.e. he controlled his anger, rather than his anger control him) get angry for the sake of God...when the right's of God had been transgressed.
* But why anger, you ask? Anger is a great motivator. When you see evil, and simply get upset, or pity "the state of the ummah", as we hear often today, then you are encouraging a certain lethargy. When people are depressed and fall into self-pity, they do not act nor work towards changing an evil. This is weak faith. But when you are angry, you are motivated into swift and decisive action which usually, by the Permission of Allah, brings about favourable results.