Divine justice has its laws, which are not always identical to those of human justice.
Let us take an example: you would like to do somebody good, but through your own ignorance or clumsiness, they are the victim of an accident.
Earthly justice, which does not perceive your motives, judges you according to your actions. Divine justice, on the other hand, which does know your good intentions, may allow human law to punish you, because it is not its concern, but it will amply reward you for your generosity.
Conversely, you may appear to behave appropriately towards someone but with the hidden intention of misleading them, and so, whereas you will be appreciated on earth, heaven will punish you because the celestial law courts judge you not according to your actions, but according to your motives. Actions and motives are not subject to the same jurisdiction.
Of course, if both your motives and your actions are divine and irreproachable you will be rewarded by both sides, and equally if you infringe the laws on both sides then both courts will condemn you.