Righteousness and justification can sometimes be misunderstood. I am quoting only in part from the CCC - if you access the link below, you can read the whole section. Worth it!
Justification and Righteousness
1987 The grace of the Holy Spirit has the power to justify us, that is, to cleanse us from our sins and to communicate to us “the righteousness of God through faith in Jesus Christ” and through Baptism:34
But if we have died with Christ, we believe that we shall also live with him. For we know that Christ being raised from the dead will never die again; death no longer has dominion over him. The death he died he died to sin, once for all, but the life he lives he lives to God. So you also must consider yourselves as dead to sin and alive to God in Christ Jesus.35
1988 Through the power of the Holy Spirit we take part in Christ’s Passion by dying to sin, and in his Resurrection by being born to a new life; we are members of his Body which is the Church, branches grafted onto the vine which is himself:36
[God] gave himself to us through his Spirit. By the participation of the Spirit, we become communicants in the divine nature. . . . For this reason, those in whom the Spirit dwells are divinized.37
1989 The first work of the grace of the Holy Spirit is conversion, effecting justification in accordance with Jesus’ proclamation at the beginning of the Gospel: "Repent, for the kingdom of heaven is at hand."38 Moved by grace, man turns toward God and away from sin, thus accepting forgiveness and righteousness from on high. "Justification is not only the remission of sins, but also the sanctification and renewal of the interior man.39
1990 Justification detaches man from sin which contradicts the love of God, and purifies his heart of sin. Justification follows upon God’s merciful initiative of offering forgiveness. It reconciles man with God. It frees from the enslavement to sin, and it heals. 1991 Justification is at the same time the acceptance of God’s righteousness through faith in Jesus Christ. Righteousness (or “justice”) here means the rectitude of divine love. With justification, faith, hope, and charity are poured into our hearts, and obedience to the divine will is granted us.
2007 With regard to God, there is no strict right to any merit on the part of man. Between God and us there is an immeasurable inequality, for we have received everything from him, our Creator. 2008 The merit of man before God in the Christian life arises from the fact that God has freely chosen to associate man with the work of his grace. The fatherly action of God is first on his own initiative, and then follows man’s free acting through his collaboration, so that the merit of good works is to be attributed in the first place to the grace of God, then to the faithful. Man’s merit, moreover, itself is due to God, for his good actions proceed in Christ, from the predispositions and assistance given by the Holy Spirit.