Justice demands restitution, but such a notion has to be understood within the realm of what is possible. For example, humans are incapable of turning back time to prevent a crime or sin from happening in the first place. God may have this power but he does not exercise it (and it would be a violation of our freewill if he did). Therefore, restitution cannot be about completely and utterly undoing a crime or sin, because such a thing is not possible.
Consider the following example: Let us say that I stole $100 from my friend, and the crime became known. Not only is my friend robbed of the money, but there is also the emotional damage that comes from a violation of trust and friendship. Justice demands restitution. I can return the $100, and I can try to repair the emotional damage by giving a sincere apology (which may or may not be enough to do the job). I may even have to do jail time because my crime also violated the law of society.
But I am unable to completely undo my crime, because there will be some form of remnant. My friend may never get over the hurt I caused, and may never be able to forget the event. He also may be less trusting with other people as a result. That is unfortunate, but there is only so far I am capable of going in order to satisfy justice in terms of restitution. The agents of justice have to realize this as well. If justice demands that I do more until a “perfect” restitution is achieved, then justice demands that I do the impossible. In demanding I do the impossible, the agents of justice would themselves be unjust.
In light of all I’ve said, generally speaking, justice is concerned with a “proper” restitution, or a “satisfactory” restitution, as opposed to a “perfect” restitution. To put this another way, a specific form of restitution can be “imperfect” and yet deemed proper, appropriate, and satisfactory. Because the restitution is imperfect anyway (whether we want it to be or not), it can be tempered by an application of mercy. After all, there is no rule that says that the only limitations placed on restitution of a crime are those born out of practical necessity (and therefore mercy, which is not a necessity, is not permissible).
Therefore, the satisfaction of justice is not invalidated by an application of mercy towards the offender.