Paul fills Galatians with statements of amazement concerning the Galatian Christians who had turned away from grace and had adopted a legalistic approach to Christian living.
Chapter 1: "I marvel that you are turning away so soon from Him who called you in the grace of Christ, to a different gospel, which is not another; but there are some who trouble you and want to pervert the gospel of Christ." (Ga 1:6–7).
In Matthew 4:15-23, Jesus began his ministry with the Gospel message to repent for the Kingdom of God is at hand, which was a light to the Gentiles, and God's law is how his audience knew what sin is (Romans 3:20), so repenting from our disobedience to it is a central part of the Gospel message, which he prophesied would be proclaimed to all nations (Matthew 24:12-14). In Romans 15:4, Paul said that OT Scripture was written for our instruction, and in 15:18-19, Paul fulfilled the Gospel by bringing Gentiles to obedience to it by word and by example, so Galatians 1:6-7 should not be misused as a weapon against the Gospel of Grace that Jesus and Paul taught.
Chapter 2: "I do not set aside the grace of God; for if righteousness comes through the law, then Christ died in vain." (Ga 2:21)
We can't earn our righteousness as the result of obeying God's law even if we manage to have perfect obedience to it (Romans 4:1-5), so that was never the goal of why we should obey it.
Chapter 3: "O foolish Galatians! Who has bewitched you that you should not obey the truth, before whose eyes Jesus Christ was clearly portrayed among you as crucified?" (Ga 3:1)
In Acts 5:32, the Spirit has been given to those who obey God, so obedience to God is part of the way to receive the Spirit, however, Galatians 3:1-2 denies that "works of the law" are part of the way to receive the Spirit, therefore that phrase does not refer to obedience to God. In Romans 3:27-31, Paul contrasted a law of works with a law of faith, so works of the law are of works while he said that our faith upholds God's law, so it is of faith, and a law that our faith upholds can't be referring to the same thing as the works of the law that are not of faith in Galatians 3:10-11.
Chapter 4: "Tell me, you who desire to be under the law, do you not hear the law?" (Ga 4:21)
If God saved the Israelites from bondage in Egypt in order to put them under bondage to His law, then it would be for bondage that God sets us free, however, Galatians 5:1 says that it is for freedom that God sets us free, and would be expressing an extremely negative view of God to think that he puts His people into bondage, but rather His law is a perfect law of freedom that blesses those who obey it (Psalms 19:7, Psalms 119:45, Psalms 119:1-3, James 1:25). In Psalms 119:142, God's law is truth, and in John 8:31-36, it is sin in transgression of God's law that puts us in bondage while it is the truth that sets us free. Moreover, God's law came through the line of the free woman, not the line of the slave woman, so that should influence the way to interpret Galatians 4.
Chapter 5: "You have become estranged from Christ, you who attempt to be justified by law; you have fallen from grace." (Ga 5:4)
All throughout the Bible, God wanted His people to repent and to return to obedience to His law and even Jesus began his ministry with that Gospel message, plus he set a sinless example for us to follow of how to walk in obedience to it, which we are instructed to follow (1 Peter 2:21-22, 1 John 2:6, 1 Corinthians 11:1), so Galatians should not be interpreted as speaking against doing this. It would be absurd to think that Paul was saying that the way to be estranged from Christ is by following the law that he spent his ministry teaching his disciples to follow by word and by example.
In Psalms 119:29-30, he wanted to put false ways far from him, for God to be gracious to him by teaching him to obey His law, and he chose the way of faithfulness by setting it before him, so this has always been the one and only way of salvation by grace through faith. In Exodus 33:13, Moses wanted God to be gracious to him by teaching him to walk in His way that he might know Him and Israel too, in 1 Kings 2:1-3, God taught how to walk in His way through His law, and in John 17:3, eternal life is knowing God and Jesus, which is again salvation by grace through faith. In Genesis 6:8-9, Noah found grace in the eyes of God, he was a righteous man, and he walked with God, so God was gracious to him by teaching him to walk in His way in obedience to His law and he was righteous because he obeyed through faith. In Romans 1:5, we have received grace in order to bring about the obedience of faith. In Titus 2:11-14, our salvation is described as being trained by grace to do what is godly, righteous, and good, and to renounce doing what is ungodly, so God gracious teaching us to obey His law is part of the content of His gift of salvation and this is what it means to be under grace, not the way to fall from it. It would be absurd to think that God was being gracious to us by teaching us how to fall from grace.
And in chapter 6, he makes this telling statement: "For not even those who are circumcised keep the law". (Ga 6:13)
Paul criticizing people for not keeping God's law is not a very good reason for why we should not keep it.
It is truly baffling when Christians set aside the grace of God and place themselves under the law.
While I agree that we are not under the law, Paul spoke about multiple different categories of law other than the Law of God, such as works of the law and the law of sin, so it is important to correctly identify which law he was saying that we are not under. For example, in Romans 7:25-8:2, Paul contrasted the Law of God with the law of sin and contrasted the Law of the Spirit of Life with the law of sin and death, and it should at least be worth considering whether the law that we are not under is the law of sin rather than the Law of God.
In Romans 6:14, Paul described the law that we are not under as being a law where sin had dominion over us, which does not describe the Law of God, which is a law where holiness, righteousness, and goodness have dominion over us (Romans 7:12), but rather it is the law of sin where sin had dominion over us. Furthermore, in Romans 6:15, being under grace does not mean that we are permitted to sin, and in 1 John 3:4, sin is the transgression of God's law, so we are still under it and are obligated to obey it. Moreover, everything else in Romans 6 speaks in favor of obedience to God's law and against sin.
You should be quicker to think that you must have misunderstood Paul than to think that it makes perfect sense to interpret a servant of God as speaking against obeying what He has commanded. If God is a legalist for giving His law to His people and Jesus is a legalist for setting a sinless example for us to follow of how to obey it, then we should all be legalists, but I don't think that is what it means to be a legalist.