Even though God’s promises defied logic, Abraham believed them anyway. He accepted God’s word as the truth. And God substituted what Abraham had (faith) for something he could never earn (righteousness.) That is “the righteousness that is by faith.” “For what saith the scripture? Abraham believed God, and it was counted unto him for righteousness.” (Romans 4:3)
When you put your faith in Jesus, God counts your faith as righteousness too. “For the promise, that he should be the heir of the world, was not to Abraham, or to his seed, through the law, but through the righteousness of faith. . . . Therefore it is of faith, that it might be by grace; to the end the promise might be sure to all the seed; not to that only which is of the law, but to that also which is of the faith of Abraham; who is the father of us all.” (Romans 4:13, 16)
If you believe that God’s word is true, then you’re going to act like you believe it. That’s the kind of faith that God counts as righteousness. “Even as Abraham believed God, and it was accounted to him for righteousness. Know ye therefore that they which are of faith, the same are the children of Abraham.” (Galatians 3:6-7)
When you were a sinner, you were free from righteousness. And now that God has declared you to be righteous, you’re free from the power of sin. “What then? Shall we sin because we are not under the law, but under grace? God forbid. Know ye not that whom ye yield yourselves servants to obey, his servants ye are to whom ye obey; whether of sin unto death, or to obedience unto righteousness? . . .
For when ye were the servants of sin, ye were free from righteousness. What fruit had ye in those things whereof ye are now ashamed? For the end of those things is death. But now being made free from sin, and become servants of God, ye have your fruit unto holiness, and the end eternal life. For the wages of sin is death but the gift of God is eternal life through Jesus Christ our Lord.” (Romans 6:15-16, 20-23)
Your salvation is based entirely on the righteousness of Jesus Christ. “And be found in him, not having mine own righteousness, which is of the law, but that which is through the faith of Christ, the righteousness which is of God by faith:” (Philippians 3:9)