What does one do to have God’s righteousness imputed to his account? “Even as David also describeth the blessedness of the man, unto whom God imputeth righteousness without works, Saying, Blessed are they whose iniquities are forgiven, and whose sins are covered. Blessed is the man to whom the LORD will not impute sin.” - Romans 4:6. “But for us also, to whom it shall be imputed, if we believe on him that raised up Jesus our Lord from the dead;” - Romans 4:24. Believe is the condition. Read Romans 4-5.
What did Christ do to have our sin imputed to him? He, kneeling in the garden, believed and received the weight of sin. God “made him to be sin for us, who knew no sin…” - 2 Corinthians 5:21. Jesus became what we are, a sinner—no, more than that, He became sin itself, “…that we might be made the righteousness of God in him.” God was willing to see Jesus as a sinner, so He could see us as righteousness. Jesus became what we are, so we can become what he is. He became a sinful son of man, so we could become sinless sons of God. It was a trade. He traded his righteousness to us for our sin. He then carried the consequences of our sin before God, so we can carry the consequences of Christ’s righteousness before God. He walked to Calvary, so we could ascend to heaven. The God who “calleth those things which be not as though they were” called His Son something He wasn’t—a sinner, so he could call us something we are not—righteous. “Blessed is the man to whom the Lord will not impute sin.” - Romans 4:8.