The key to understanding this issue is knowing that the Old Testament law was given to the nation of Israel, not to Christians.
Well obviously there were no Christians in the OT (as Christ had not yet come).
But there are a couple of dozen verses that say Gentiles who wanted to become believers fell under the law.
Ecc 12:13; The conclusion, when all has been heard, is: fear God and
keep His commandments, because
this applies to every person.
Every person, not just Jews. Rahab was a Gentile, Ruth was a Gentile, the entire city of Sodom/Gomorrah was Gentiles,
Ninevah, where God sent Jonah was a Gentile city.
Jos 8:32; He wrote there on the stones a copy of
the law of Moses, which he had written, in the presence of the sons of Israel.
Jos 8:33; All Israel with their elders and officers and their judges were standing on both sides of the ark before the Levitical priests who carried the ark of the covenant of the LORD,
the Gentiles as well as the Israelites. Half of them stood in front of Mount Gerizim and half of them in front of Mount Ebal, just as Moses the servant of the LORD had given command at first to bless the people of Israel.
Jos 8:34; Then afterward he read all the words of the law,
the blessing and the curse, according to all that is written in the book of the law.
Jos 8:35; There was not a word of all that Moses had commanded which Joshua did not read before all the assembly of Israel with the women and the little ones
and the Gentiles who were living among them.
Ishmael (the son of Hagar) was a Gentile, why did he have to be circumcised?
Timothy was a Greek, why did he have to be circumcised?
Anyone who preaches Gentiles were never under the law doesn't know the Bible.
Rom 2:11; God does not play favorites.
Rom 2:12; Here's the reason:
Whoever sins without having laws from God will still be condemned to destruction. And whoever has laws from God and sins will still be judged by them.
Rom 2:13;
People who merely listen to laws from God don't have God's approval. Rather, people who do what those laws demand will have God's approval.
Rom 2:14; For example,
whenever non-Jews who don't have laws from God do by nature the things that Moses' Teachings contain, they are a law to themselves even though they don't have any laws from God.
Rom 2:15;
They show that some requirements found in Moses' Teachings are written in their hearts. Their consciences speak to them. Their thoughts accuse them on one occasion and defend them on another.