"But, unlike Adam, when he is tempted he (Jesus) does not sin. He is the only human being who perfectly obeys God, his Father. He is, therefore, the one person to have lived who does not deserve to be banished from God's presence. But on the cross he willingly faces the punishment that we all deserve, as sinners who are bound up with the first Adam. As a result, if we trust in him, we enter into a new humanity, headed not by Adam, the sinner, but by Jesus, the righteous new Adam. Paul writes, '. . . just as through the disobedience of one man [Adam] the many were made sinners, so also through the obedience of the one man [Christ] the many will be made righteous' (Romans 5:19)."
I thought of the verse at the top of the post after I had read the previous paragraph in Vaughn Roberts' book 'God's Big Picture.' I was then inspired to check the ESV Study Bible for some commentary on the verse. The 'big idea' in the verse is captured better in the study Bible's notes than I could express, so I copied them below. It is long, but it's good.
2 Cor. 5:21 This verse is one of the most important in all of Scripture for understanding the meaning of the atonement and justification. Here we see that the one who knew no sin is Jesus Christ and that he (God) made him (Christ) to be sin (Gk. hamartia, "sin"). This means that God the Father made Christ to be regarded and treated as "sin" even though Christ himself never sinned (Heb. 4:15; cf. Gal 3:13). Further, we see that God did this for our sake that is, God regarded and treated "our" sin (the sin of all who would believe in Christ) as if our sin belonged not to us but to Christ himself. Thus Christ "died for all" (2 Cor. 5:14) and, as Peter wrote, "He himself bore our sins in his body on the tree" (1Pet. 2:24). In becoming sin "for our sake," Christ became our substitute - that is, Christ took our sin upon himself and, as our substitute, thereby bore the wrath of God (the punishment that we deserve) in our place ("for our sake"). Thus the technical term for this foundational doctrine of the Christian faith is the substitutionary atonement - that Christ has provided the atoning sacrifice as "our" substitute, for the sins of all who believe (cf. Rom 3:23-25). The background for this is Isaiah 53 from the Greek (Septuagint) translation of the Hebrew OT, which included the most lengthy and detailed OT prophecy of Christ's death and which contains numerous parallels to 2 Cor 5:21. Isaiah's prophecy specifically used the Greek word for "sin" (Gk. hamartia) five times (as indicated below in italics) with reference to the coming Savior (the Suffering Servant) in just a few verses - e.g., "surely he has borne our griefs" (Isa. 53:4); "He was crushed for our iniquities" (Isa. 53:5); "the Lord has laid on him the iniquity of us all" (Isa 53:6); "he shall bear the iniquities" (Isa. 53:11); "he bore the sin of many" (Isa. 53:12). In a precise fulfillment of the is prophecy, Christ became "sin" for these who believe in him, so that in him we might become the righteousness of God. This means that just as God imputed our sin and guilt to Christ ("he made him to be sin") so God also imputes the righteousness of Christ - a righteousness that is not our own - to all who believe in Christ. Because Christ bore the sins of those who believe, God regards and treats believers as having the legal status of "righteousness" (Gk. dikaiosyne). This righteousness belongs to believers because they are "in him," that is, "in Christ" (e.g., Rom. 3:22; 5:18; 1Cor. 1:30; 2 Cor. 5:17, 19; Phil. 3:9). Therefore "the righteousness of God" (which is imputed to believers) is also the righteousness of Christ - that is, the righteousness and the legal status that belongs to Christ as a result of Christ having lived as one who "knew no sin." This then is the heart of the doctrine of justification; God regards (or counts) believers as forgiven and God declares and treats them as forgiven, because God the Father has imputed the believer's sin to Christ and because God the Father likewise imputes Christ's righteousness to the believer.