If Christ had only earned forgiveness of sins for us, then we would not merit heaven. Our guilt would have been removed, but we would simply be in the position of Adam and Eve before they had done anything good or bad and before they had passed a time of probation successfully. To be established in righteousness forever and to have their fellowship with God made sure forever, Adam and Eve had to obey God perfectly over a period of time. Then God would have looked on their faithful obedience with pleasure and delight, and they would have lived with him in fellowship forever.
For this reason, Christ had to live a life of perfect obedience to God in order to earn righteousness for us. He had to obey the law for his whole life on our behalf so that the positive merits of his perfect obedience would be counted for us. Sometimes this is called Christ’s “active obedience,” while his suffering and dying for our sins is called his “passive obedience.” Paul says his goal is that he may be found in Christ, “not having a righteousness of [his] own based on law, but that which is through faith in Christ the righteousness from God that depends on faith” (Phil. 3:9). It is not just moral neutrality that Paul knows he needs from Christ (that is, a clean slate with sins forgiven), but a positive moral righteousness. And he knows that that cannot come from himself, but must come through faith in Christ. Similarly, Paul says that Christ has been made “our righteousness” (1 Cor. 1:30). And he quite explicitly says, “For as by one man’s disobedience many were made sinners, so by one man’s obedience many will be made righteous” (Rom. 5:19).