What are, in the Bible, the ‘works of the law’? The Ten Commandments or only things such as circumcision and the Sabbath?
Surely not only the ceremonial law, but also the Ten Commandments. When you abide by them without faith in Christ, nevertheless never killing anyone, nor stealing, nor committing adultery, then you possibly become as good as Gandhi or Nelson Mandela. But that has as much to do with the righteousness of God as a rowanberry has in common with a fig.
You will not be saved by doing good things because that is an external matter. Only when you are good within yourself first, then the things you do are also good in themselves. First you have to change, and only then works. And that happens by faith.