Many great saints and writers have written on this topic. Here is how I understand it.
God is infinitely just. This means that every offense we commit will be given its deserved consequence. And the consequence of sin is death, since every sin is a willful act against the infinite God and the harmony of the world.
But we are God’s children, and God loves all of His children. He does not want any of them to end in death. And God is also infinitely merciful.
So, while He sends His Truth to condemn us, He also sends Himself to redeem us.
The way He did that is He came in Jesus to pay for our debt.
Every sin incurs two effects: the rupture of relationship with God, self, others and nature; and the harm inflicted on others. It is like throwing a ball and breaking your neighbour’s window. We need to apologize for the act and we need to pay for the damaged window. Sin is the same: we must repent and pay for the damage with our life, if justice is to be served.
But while we are the only ones who can apologize for our own actions, someone else can help pay for the damage, in order to save us from death.
That was what Jesus did on the cross. He, the innocent Lamb of God, took all our sins on Himself, and paid for the damage we caused.
And because He is God, He can do that once and for all, one payment, one shedding of blood, for the sum of all the offenses committed from our first parents to the last human beings before the Final Judgement.
Everyone who repents can obtain this free gift of salvation.
This is pure mercy, and it does not take away God’s justice. Justice demands compensation, and compensation has been given in full.
Another way to look at this is: we look at justice in a negative way. The worldly sense of justice is based on com measurable punishment, but it has often degenerated into an equality of pain. You caused me pain, you have to suffer as much, if not more.
God’s justice is an equality of salvation. He wants all to repent, to turn towards goodness and life. As soon as a sinner turns back to him, all is forgiven and forgotten. This is what we are made for, to be healed and saved and transformed to be saints.
This is why Jesus came to serve sinners. He identified Himself with the tax collectors, prostitutes, and other public sinners. He forgave the criminal crucified with Him because of a mere request, and He asked the Father to forgive those who crucified Him. He wants them to turn and be saved. God does not take pleasure in the destruction of sinners, but in their repentance and salvation.