In Paul’s letters and in James the terms works, the law, and works of the law are used in a somewhat inconsistent and confusing manner.
In both Paul and James both faith and good works (moral and beneficent behavior) are required, but the emphasis differs with Paul emphasizing faith, and James more balanced or perhaps even emphasizing good works.
The letter James is quite vague on the law in terms of the Mosaic rituals. He writes about the (perfect) law of liberty (James 1:25 and 2:12). But the author of James does refer to the laws of the Torah ---
If, however, you are fulfilling the royal law according to the Scripture, “Love your neighbor as yourself,” you are doing well. But if you show partiality, you are committing sin and are convicted by the law as transgressors. For whoever keeps the whole law and yet stumbles in one point, he has become guilty of all. For He who said, “Do not commit adultery,” also said, “Do not murder.” Now if you do not commit adultery, but do commit murder, you have become a transgressor of the law. So speak and so act as those who are to be judged by the law of liberty. (James 2:8-12)
Paul expresses similar concepts ---
For as many as are of works of the Law are under a curse, for it has been written: "Cursed is everyone who does not continue all things having been written in the book of the Law, to do them." (Galatians 3:10)
And I testify again to every man who receives circumcision, that he is under obligation to keep the whole Law. (Galatians 5:3)
Circumcision is nothing, and uncircumcision is nothing, but what matters is the keeping of the commandments of God. (1 Corinthians 7:19)
Yet, Paul also wrote that the Mosaic laws could not provide justification ---
Nevertheless knowing that a man is not justified by the works of the Law but through faith in Christ Jesus, even we have believed in Christ Jesus, so that we may be justified by faith in Christ and not by the works of the Law; since by the works of the Law no flesh will be justified. (Galatians 2:16)
So which is it according to Paul --- does keeping the whole law provide justification or not?
Paul touches on the problem in Galatians, but the problem is more clearly presented by the author of Romans --- human flesh is weak and not capable of keeping the entire law
For the flesh craves what is contrary to the Spirit, and the Spirit what is contrary to the flesh. They are opposed to each other, so that you do not do what you want. (Galatians 5:17)
What shall we say then? Is the Law sin? May it never be! On the contrary, I would not have come to know sin except through the Law … for sin, taking an opportunity through the commandment, deceived me and through it killed me. So then, the Law is holy, and the commandment is holy and righteous and good … For we know that the Law is spiritual, but I am of flesh, sold into bondage to sin. For what I am doing, I do not understand; for I am not practicing what I would like to do, but I am doing the very thing I hate … For I know that nothing good dwells in me, that is, in my flesh; for the willing is present in me, but the doing of the good is not … For what the Law could not do, weak as it was through the flesh, God did: sending His own Son in the likeness of sinful flesh and as an offering for sin, He condemned sin in the flesh, so that the requirement of the Law might be fulfilled in us, who do not walk according to the flesh but according to the Spirit … because the mind set on the flesh is hostile toward God; for it does not subject itself to the law of God, for it is not even able to do so ... (Romans 7:7 – 8:7)