When someone is convicted of breaking the law, for example by stealing a car, they are sentenced and must face the punishment. And that's the right thing for a society to do. It is fair and just.
The same is true when we break one of God's laws. We are guilty before God. As lawbreakers we deserve punishment.
But as believers we are 100% assured we will not be punished! Through Christ, we have been justified--declared innocent before God! But God is still just because Christ took our place and our penalty on Himself on the cross. All the wrath of God was fully satified, all the demands of His justice were fully met in Christ.
More on this topic....
Look at John 5:24 closely,
"Truly, truly, I say to you, he who hears My word, and believes Him who sent Me, has eternal life, and does not come into judgment, but has passed out of death into life" (NASB).
This verse says the case is dismissed against us! How did this happen?
Romans 3:25-27 says that Christ is literally our "mercy seat" (Greek, hilasterion),
"whom God displayed publicly as a "mercy seat" in His blood through faith....so that He would be just and the justifier of the one who has faith in Jesus."
The word often translated "propitiation" or "atoning sacrifice" is actually from a Hebrew Old Testament word for the gold lid on top of the Ark of the Covenant. (Ark means chest or box.)
It is called the "mercy seat" because the chest or Ark was a representation of God's throne, so the lid is where the seat would be. Once a year, on the Day of Atonement, in the innermost part of the Temple, the High Priest would pour the blood of the sacrifice on top of this golden lid or seat. Inside the Ark were the stone tablets that contain the original Ten Commandments. The Law!
This means that symbolically the blood came between God (above the lid) and the Law (inside the Ark). So if God were to look down, so to speak, He'd see the blood "covering" the Law. The payment was made! The Day of Atonement in Hebrew is Yom Kippur, the "day of covering." Picture it this way:
God
The sacrifice blood on "mercy seat" (lid)
The Law
Of course the blood of goats and bulls cannot take away sin (Hebrews 10:4). Only Christ's blood could do that (Hebrews 10:10)!
So God remains "just" although He "justifies" us!