God will judge our works
The Bible teaches that salvation is a gift of God that we receive through faith and is not the result of any work that we have done.
For by grace you have been saved through faith. And this is not your own doing; it is the gift of God, not a result of works, so that no one may boast.
But the Bible also says that we will be judged for what we do.
For we must all appear before the judgment seat of Christ, so that each one may receive what is due for what he has done in the body, whether good or evil.
2 Corinthians 5:10
How can these two facts be reconciled?
I quoted Ephesians 2:8,9 to show that salvation is not by works. The next verse explains the relationship between salvation and works.
For we are his workmanship, created in Christ Jesus for good works, which God prepared beforehand, that we should walk in them.
God does not save us because of anything we have done but we are saved so we will do good works and those works will be judged.
According to the grace of God given to me, like a skilled master builder I laid a foundation, and someone else is building upon it. Let each one take care how he builds upon it. For no one can lay a foundation other than that which is laid, which is Jesus Christ.
Now if anyone builds on the foundation with gold, silver, precious stones, wood, hay, straw—each one’s work will become manifest, for the Day will disclose it, because it will be revealed by fire, and the fire will test what sort of work each one has done. If the work that anyone has built on the foundation survives, he will receive a reward. If anyone’s work is burned up, he will suffer loss, though he himself will be saved, but only as through fire.
1 Corinthians 3:10-15
On earth some people are rich and others are poor. The same thing will be true in Heaven but with one difference. Those who are rich will have earned their wealth by their faithful service to God during their time on earth. Those who are poor will deserve their poverty because of their failure to carry out the work God gave them to do.
The works of those who are not saved will also be judged.
Then I saw a great white throne and him who was seated on it. From his presence earth and sky fled away, and no place was found for them. And I saw the dead, great and small, standing before the throne, and books were opened. Then another book was opened, which is the book of life. And the dead were judged by what was written in the books, according to what they had done.
The books contain a record of what the dead had done while they were still alive and their works are judged. But whether or not they are thrown into the lake of fire isn’t dependent on their what is recorded in these books but on another book.
And if anyone’s name was not found written in the book of life, he was thrown into the lake of fire.
If their final destiny depends only on whether their names are in the book of life, then what is the purpose of judging their works? We can see the answer if we compare this judgment with how the works of Christians are judged. All sinners deserve eternal punishment but not all deserve the same degree of punishment. Whether we are saved or lost, the way we live will have an effect on our eternal destiny.