A person commits a crime, is caught, and subsequently is convicted of this crime.
The judge, being a righteous judge, requires some form of restitution for this transgression of the law. He therefore imposes on the criminal a monetary fine.
However, in this case, the fine was totally beyond the person's ability to pay.
Now, it just so happens, that in this case, the criminal being tried was the judge's own son!
So, the judge does, what any loving father would do; He removes his judicial robe, comes around in front of the bench, and pays the fine for his son.
Now let's make the analogy...
The penalty had to be paid. The criminal doesn't have to be the one to make the payment, but nonetheless, the penalty MUST be paid.
It would not make much sense for the child to refuse the father's payment and insist on going to jail.
The point is that God is a righteous judge, AND a loving father.
As the judge, He sees our sin and says, "YOU have sinned against me, the penalty is DEATH, but I LOVE YOU and will pay the penalty MYSELF."
Then, as a father, He took off His heavenly robe, stepped over to our side of the bench, and paid for OUR sins by HIS death on the cross.