"God made him who had no sin to be sin for us, so that in him we might become the righteousness of God." 2 Corinthians 5:21
The record of our lives is spliced into the history of Someone Else, who bears all the consequences on himself. And his record is written into our stories, so that all the advantages of a perfect life in the sight of God become ours. And all we do is receive this with the empty hands of faith.
The wonderful surprise called justification by faith, centered in the cross of Jesus.