Nowhere does the Bible say that, but rather it says that the Spirit has the role of leading us to obey God's law (Ezekiel 36:26-27)
There can be many reasons for obeying God's law other than trying to earn our righteousness, such as faith and love, so the fact that we do not earn our righteousness does not mean that the purpose of the law is to judge and condemn. In Romans 2:13, Paul said that only doers of the law will be declared righteous, so must be a reason that being declared righteous requires us to choose to be doers of the law other than in order to earn it. In Romans 3:21-22, it does not say that the Law and the Prophets testified that our righteousness is earned as a wage by having good enough obedience, but rather the only way to become righteous that is testified about by the Law and the Prophets is through faith in Christ for all who believe, so our faith in Christ has always been the reason for why we should obey God's law, and by the same faith we are declared righteous. Not even earthly parents give instructions to their children for the goal of judging and condemning them, and that is much more true for our heavenly Father who knows how to give good gifts, whose law was given as a priceless gift for our own good in order to bless us (Deuteronomy 6:24, 10:12-13).
Jesus never criticized the Pharisees for obeying God's law, but he did criticize them for not obeying it or for not obeying it correctly, and he called them to come to a fuller obedience to it that was in accordance with its weightier matters and free from hypocrisy. In Matthew 19:17, Jesus said that the way to eternal life is by obeying God's commandments, not that God's commandments are the way to enter eternal damnation. If you think that God has the goal of brining about our eternal damnation, then that is expressing an extremely negative view of God, where do not think that God should be trusted to guide us in how we should live through His law, which is the opposite of faith.
You refuse to obey God's law, which means that you are lawlessness and disobedient, so if you agree with what Paul said that the law is for the lawless and disobedient, then you should think that the law is for you. Nothing that I've said is calling Paul a liar.
The Bible repeatedly says that if we love God, then we will obey His commandments, while not once does it say that if we love God, then we do not need God's commandments. Likewise, in Ezekiel 36:26-27, the Spirit has the role of leading us to obey God's commandments. You should be quicker to think that you must have misunderstood what Paul said than to think that it makes perfect sense to think living righteously is only for the unrighteous while the righteous are free to live unrighteously. That's like thinking that cowards live courageously while the courageous live cowardly, which is absurd. Saying that someone has a character trait is saying that they are someone who expresses that character trait, which is why the righteous are those on whose heart is God's law (Isaiah 51:7).