Justice and mercy are two separate entities. Justice has to do with the application of the law; mercy is the application of what the law lacks: compassion.
We know that the Holy Bible contains laws, besides the Ten Commandments. The Law of Moses had to be followed to the letter. The Gospel Law of Jesus required baptism by immersion, to name a few. Strict application of law was not condoned by Jesus, especially when compassion by the judge was absent.
Paul the Apostle wrote that "the letter killeth, but the spirit giveth life." 2 Corinthians 3:6; KJV). Observing the letter of the law may be commendable when it is applied fairly; but when it is not, then compassion from the heart could mitigate the harshness of the letter of the law.
Jesus was confronted by a situation where a woman had been caught in adultery. The accusers, the scribes and the Pharisees, brought her to Jesus to see what He would do. After hearing their arguments, He asked them:
"He that is without sin among you, let him first cast a stone at her.
"And again he stooped down, and wrote on the ground. [What did He write? An enumeration of their sins? It does not say.]
"And they which heard it, being convicted by their own conscience, went out one by one, beginning at the eldest, even unto the last: and Jesus was left alone, and the woman standing in the midst.
"When Jesus had lifted up himself, and saw none but the woman, he said unto her, Woman, where are those thine accusers? hath no man condemned thee?
"She said, No man, Lord. And Jesus said unto her, Neither do I condemn thee: go, and sin no more." (John 8:7-11).
The Law of Moses required the stoning of the woman, but Jesus exercised mercy or compassion upon the woman.
We all are sinners or lawbreakers according the record, so the Law has a claim upon us, but who will release us from the Law? Jesus. He paid for our sins by taking the Law upon himself, thus exercising compassion.
"But he was wounded for our transgressions, he was bruised for our iniquities: the chastisement of our peace was upon him; and with his stripes we are healed." (Isaiah 53:5).
The Atonement of Jesus was an act of compassion or mercy in our behalf, so the strict letter of the law or justice would not fall upon us with all of its weight.