What is Justice? It is rendering what is Due to the person to whom it is due.
What is Law? Law is the requirement of a Lawgiver (for without a Law-giver, there is no Law) upon those subservient to the Lawgiver, such that they will operate within the society ruled by the Lawgiver as good citizens, as citizens beneficial to the common good of the persons of the society.
But Law itself is not Justice. It is a sort of “fence” within which Justice is possible, while outside this “fence” no justice is possible.
For example, the LORD’s justice (SalamKhan could probably make a parallel statement for Allah’s justice) - the LORD’s justice is that Love is Due (‘I AM’ the LORD your God; you shall love the LORD your God with all your heart, soul, mind, strength; and you shall love your neighbor as yourself."
That is justice to the LORD, our God.
Do that, and you have not missed the mark (“missing the mark” is a better English phrase than “sin”).
However, one can obey the Law yet not hit the mark.
If I do not steal, if I do not kill, this still does not mean that I have hit the mark and poured out my life in Love to my neighbor, helping him as if he were Me.
If I do not go after other Gods, if I do not use his Name incorrectly, if I attend worship correctly, this still does not mean that I have hit the mark and loved the LORD, pouring out my whole being and life into him in love, being his servant with my whole heart, soul, mind, and strength.
I can “obey the law”, yet still have no love. Thus, there is no justice done, and I have missed the mark.
However, there is help in the Law - if it is obeyed, one is in the “region” where Love can be done. If I actually kill my neighbor, there is no chance for me to love him. But if I do not kill my neighbor and do not steal from him and do not speak falsely of him, then I have the possibility of doing good to him, of helping and caring for him. The Law is like a light that enables me to see that, in the mind of my GOD, my neighbor is important, and therefore my neighbor should be recognized with importance by me. If I act like my GOD, I will see this importance in that person next to me. Then there is Justice to Man and to GOD.