The way to become a character trait is not by the results of our works, but through the believe that that trait ought to govern the way that we live. For example, it is not the case that if we do enough courageous actions first, then we earn the trait of being courageous as the result, but rather the way to become courageous is through faith that we ought to practice courageousness. Likewise, we do not earn righteousness as a wage as the result of doing enough righteous actions, but rather the way to become righteous is through faith that we ought to live righteously. In other words, we become righteous by faith apart from needing to have done any works to become righteous, but becoming righteous through faith means to become someone who practices righteousness through that same faith, which is why the faith by which we are declared righteous does not abolish our need to practice righteousness in obedience to God's law, but rather our faith upholds it (Romans 3:27-31). God's law is His instructions for how to practice righteousness, not for how to become righteous, which is why there are many verses that speak against trying to become righteous as the result of our obedience to it while the righteous are those on whose heart is God's law (Isaiah 51:7).