"Then Jesus arrived from Galilee at the Jordan coming to John, to be baptized by him. But John tried to prevent Him, saying, "I have need to be baptized by You, and do You come to me?" But Jesus answering said to him, "Permit it at this time; for in this way it is fitting for us to fulfill all righteousness." Then he permitted Him." - Matthew 3:13-15
"But by His doing you are in Christ Jesus, who became to us wisdom from God, and righteousness and sanctification, and redemption, so that, just as it is written, "LET HIM WHO BOASTS, BOAST IN THE LORD." - 1 Corinthians 1:30-31
CHRIST DIED FOR OUR SINS, AND LIVED FOR OUR RIGHTEOUSNESS
The Lord Jesus Christ not only died an atoning death for our sins, but He also lived a sinless life that perfectly fulfilled the righteous standards of the law. If all that was necessary for our justification was the death of Jesus on the cross, He could have come down to earth on a parachute on Good Friday, died on the cross for us, and three days later, risen again. But we all know that this is not what happened. Why? Because that would never have been enough.
The good news of the Gospel is certainly that Christ died for our sins.. but it also includes the fact that He lived for our righteousness. For more than 33 years, Christ was tempted in every way like us, yet He was without sin (Heb. 4:15). Christ is the only One who can say that He loved His Father perfectly in life, with all His heart, soul, mind and strength.
At the cross then, all our sins were laid on Him (though of course, He remained the holy and spotless Lamb of God, in and of Himself) and as our sin bearer, He was punished in our place. As the angel declared to Joseph in Matthew 1:21, "you shall call His name Jesus, for He will save His people from their sins."
"He Himself bore our sins in His body on the tree" (1 Pet. 2:24).
Isa 53:5, 6 says, "But He was pierced through for our transgressions, He was crushed for our iniquities; the chastening for our well-being fell upon Him, and by His scourging we are healed. All of us like sheep have gone astray, each of us has turned to his own way; but the LORD has caused the iniquity of us all to fall on Him."
But that is far from all of the story. There was a double imputation that took place on the cross. If Christ had merely paid the penalty for our sins, our debt to God would have been cancelled, and no punishment would be due to us, thank God! But that is not nearly enough to gain an entry into heaven. That would simply remove the outstanding debt we owed to God and bring us to zero... and zero is not enough. Jesus said, "Unless your righteousness (positive) exceeds that of the scribes and Pharisees you shall in no way enter the kingdom of God." (Matt. 5:20)
We as sinners not only need the removal of the negative (our sin) but the presence of the positive... full and complete righteousness to be able to stand before a holy God just in His sight. So not only were our sins imputed to Christ and He bore their full punishment for us on the cross, but positively, the righteousness of Christ was imputed to us. The punishment due to us because of our sin came upon Him, and the pleasure of God due to Jesus' complete obedience to every jot and tittle of the law, came upon us. The very righteousness of Jesus Christ is the righteousness imputed to us by grace alone, through faith in Christ alone. This righteousness is one that has perfectly fulfilled the entire demands of the law of God.
The work of Christ is perfect in every respect, and perfect in every aspect. The righteousness now enjoyed by the believer is an alien one (one that comes from outside of himself) for it is the righteousness of Christ Himself. It comes to us as a gift, not something earned (Rom. 5:17), and is the cause of our rejoicing in the direct presence of the Lord. "For He (God) made Him (Jesus) who knew no sin, to become sin for us, that we might be made the righteousness of God in Him." 2 Cor. 5:21. As believers in Christ, we've been made righteous with a righteousness that has never known sin, and has fully complied with all the righteous demands of the law. Hallelujah! What a Savior!