Justice is not always viewed as "an eye for an eye, a tooth for a tooth". It isn't difficult to see why justice would be a virtue. A society where bad people get more and better than they deserve while good people get less and worse than they deserve is one which is corrupt, inefficient, and ripe for revolution. It is, in fact, the basic premise of all revolutionaries that society is unjust and needs to be reformed at a basic level. Perfect justice would thus appear to be a virtue not only because it is fair, but also because it results in a more peaceful and harmonious society overall.
At the same time, mercy is often regarded as an important virtue - a society where no one ever showed or experienced mercy would be one which is stifling, restrictive, and would appear to be lacking in the basic principle of kindness. That is odd, however, because mercy essentially requires that justice *not be done. One needs to understand here that mercy isn't a matter of being kind or nice, although such qualities may lead one to be more likely to show mercy. Mercy also isn't the same thing as sympathy or pity.
What mercy entails is that something less than justice be one. If a convicted criminal asks for mercy, he is asking that he receive a punishment that is less than what he is really due. When a Christian begs God for mercy, he is asking that God punish him less than what God is justified in doing. In a society where mercy reigns, doesn't that require that justice be abandoned?
Perhaps not, because justice also isn't the opposite of mercy: if we adopt the premises of virtue ethics as described by Aristotle, we would conclude that mercy lies between the vices of cruelty and and uncaring, while justice lies between the vices of cruelty and softness. So, both are contrasted with the vice of cruelty, but still they aren't the same, and are in fact often at odds with one another.
And make no mistake, they are indeed often in conflict. There is a great danger in showing mercy because if used too often or in the wrong circumstances, it can actually undermine itself. Many philosophers and legal theorists have noted that the more one pardons crimes, the more one also emboldens criminals, because you are essentially telling them that their chances of getting away without paying the proper price have increased. That, in turn, is one of the things which drives revolutions: the perception of that the system is unfair.
Justice is required because a good and functioning society requires the presence of justice - as long as people trust that justice will be done, they will better be able to trust one another. Mercy, however, is also required because as A. C. Grayling has written, "we all need mercy ourselves." The remission of moral debts may embolden sin, but it may also embolden virtue by giving people a second chance.
In conclusion, justice and mercy can never coexist as long as the principles of both contradict each other. Knowing when to show mercy and when to show strict justice is the key in navigating through the dangers that an excess of either may threaten.