Jesus didn't just bear all of our sins on the cross. He also bore all of God's wrath for us so we could live free from the law.
The purpose of the law is to reveal sin. The Gospel of Jesus Christ reveals a righteousness that is not earned. It is a gift from God.