The apostle Paul made it clear that we all must continue the process of God's gracious transformation: "And do not be conformed to this world, but be transformed by the renewing of your mind, that you may prove what is that good and acceptable and perfect will of God" (Rom 12:2).
Each of us had a starting point. When we become more like Christ, we should lose the habits and values that contradict God's Word.
As for being "justified by works," we must understand James's reasoning. He was not talking about the faith that saves us from sin but, rather, the faith that delivers (saves) us from failing the trials that come into our lives (James 1:2-18). In James 2, the trial (testing of our faith) is how we react to a wealthy man who comes into our assembly. Do we treat him better than a poor man? Our behavior exposes our faith-or lack of it. In this context, people are justified by works (v.18).
James noted the difference Abraham's justification from sin (Gen 15:6) and his experience in Genesis 22 (approximately 40 years later), when he was justified by works (James 2:21). His willingness to sacrifice Isaac enabled him to pass the test God had given him (Heb 11:17-19).
The Greek word for "justify" (dikaioo) is used in two ways in the New Testament. The main meaning is "to declare righteous," as in Romans 3:23-24, 27-30. But a second meaning is "to show to be righteous," as in Luke 7:29 and James 2.
In Genesis 15:6, Abraham was declared righteous by God because he believed God's promise that his descendants would be as numerous as the stars. In Genesis 22, Abraham was shown to be (already) righteous because he was willing to sacrifice Isaac, yet still believing God would fulfill His promise through Isaac.
It appears Rahab was being shown to be (already) righteous because "she received the messengers and sent them out another way" (James 2:25). She had already acknowledged the God of Israel as "God in heaven above and on earth beneath" (Josh 2:11).
Including Rahab in Jesus' genealogy and in the halls of the faithful reminds us that it is faith that pleases God. He embraces it wherever He finds it, "But God, who is rich in mercy, because of His great love with which He loved us, even when we were dead in trespasses, made us alive together with God (by grace you have been saved), and raised us up together, and made us sit together in the heavenly places in Christ Jesus, that is the ages to come He might show the exceeding riches of His grace in His kindness toward us in Christ Jesus" (Eph 2:4-7).
God takes great delight redeeming people, no matter what their circumstances. What better time to celebrate the exceeding riches of His grace than at Christmas, when we celebrate the arrival of Rahab's greater Son.