Why is it that Islam allows revenge when harm is inflicted to a person?

According to Islam, the first choice for such a person is to forgive the person who inflicted harm. Revenge is the second option. However, there is a condition to taking this second option. Revenge cannot be taken on one's own from the person who has caused harm. One should refer one's case to an established court and ask for justice. After the judicial enquiry and hearing of witnesses, the court will issues its order. Then, the person who has inflicted harm will be punished according to law. Without going through this judicial procedure, no revenge or any such act is permissible in Islam.