Michael Horton in The Gospel-Driven Life:
This is the scandal of justification: How can God declare us righteous if we are not inherently righteous? Isn’t this a legal fiction? Doesn’t it make God a liar? But that’s like thinking that God cannot say, ‘Let there be light’ unless there is already a sun to give it. God himself creates the conditions necessary for the existence of his work. When he says, ‘Let there be light!’ the sun exists. When he says, ‘Let this ungodly person be righteous,’ ‘this barren woman be pregnant,’ ‘this faithless person embrace my Word,’ it is so.
When we really understand justification, we really understand how God works with us in every aspect of our lives before him. Christ lived the purpose-driven life so that we would inherit his righteousness through faith and be promise-driven people in a purpose-driven world. He did gain the everlasting inheritance by obedience to everything God commanded, driven by the purpose of fulfilling the law for us, in perfect love of God and neighbor, and he bore its judgments against us. His resurrection guarantees that the law of sin and death does not have the last word over us. He fulfilled the original purpose and commission for human existence, glorifying and enjoying his Father to the fullest. And he did this as our covenantal head, our representative, not simply as a moral example. Just as we were ‘in Adam’ at the fall, we were legally included ‘in Christ’ as he fulfilled all righteousness, bore our sins, and rose from the dead in victory.