It is important to realize that our Lord Jesus Christ perfectly fulfilled the law of God, both in its requirements and its penalty. He did what Adam failed to do render perfect obedience to the law of God. Then by His death He completely paid the penalty of a broken law. So, from the standpoint of obedience to the law and of paying the penalty for breaking the law, He perfectly fulfilled the law of God.
Therefore when God justifies us, or declares us righteous, He does not create some sort of legal fiction, calling something righteous that is not. Rather, He declares us righteous on the basis of the real, accomplished righteousness of Jesus Christ, which is imputed or credited to us through faith.
HT: Reformed Quotes