If there had been a law given that could impart life (including the two greatest ones), verily righteousness should have been by the law. Galatians 3:21.
Galatians 3
21Is the Law then contrary to the promises of God? May it never be! For if a law had been given which was able to impart life, then righteousness would indeed have been based on law.22But the Scripture has shut up everyone under sin, so that the promise by faith in Jesus Christ might be given to those who believe.
Gal 3:21 says that if getting into a relationship with God was the advantage Jews had, then Law would have been the way that the advantage was gained. However, Law actually pointed out Israel's sin, non qualification.
No one is saved through law-keeping, Galatians 2:16, Romans 3:20, Galatians 2:21.
Galatians 2
14But when I saw that they were not straightforward about the truth of the gospel, I said to Cephas in the presence of all, “If you, being a Jew, live like the Gentiles and not like the Jews, how is it that you compel the Gentiles to live like Jews?
15“We are Jews by nature and not sinners from among the Gentiles; 16nevertheless 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
21“I do not nullify the grace of God, for if righteousness comes through the Law, then Christ died needlessly.”
Gal 2:16 says there is no salvation advantage in being a Jew. It does not say a person will not be saved by doing good works. Ditto verse 21.
Romans 3
19 Now we know that whatever the law says it speaks to those who are under the law, so that every mouth may be stopped, and the whole world may be held accountable to God. 20 For by works of the law no human being will be justified in his sight, since through the law comes knowledge of sin.
Romans 3:20 says that the law, instead of giving Jews an advantage, actually shows Israel she is sinful. It doesn't say that people aren't in a good relationship with God if they do good works.