Paul clearly shared the good news of grace (gospel) with the Galatian people.
When they heard the good news, they embraced it.
This good news was righteousness (eternally clean, pure, innocent of sin, right with and accepted by God) came by grace (Jesus completely taking our unrighteousness at the cross) through faith (freely receiving the righteousness of Jesus).
Yet false teachers infiltrated the grace churches in Galatia, corrupting the good news of grace by convincing the people that righteousness was not of grace, nor was it received by faith in Jesus, but rather it was earned by following the days, diets, duties, and demands of the law of Moses (morality and religious activity).
The false teachers communicated to the people that if they failed to follow the law of Moses, then they were under a curse, meaning the curses of Deuteronomy 28-29 would come upon them.
This was true for the nation of Israel when the people lived according to the Book of the Law, the law of Moses (Deuteronomy 31:26).
God, seeking to reach the nations of the world with his love and grace, selected Israel to be his light to the nations.
Knowing the hearts of mankind, God gave them the law, a system of blessings and curses to motivate them to not mix with the false gods of the nations of the world but to remain separate so they could be a beacon of light of the One True God to them.
The law system was much like parents who give children a system of rewards and punishments to motivate a child to good behavior.
The majority of the old testament records the continual rebellion of Israel to the law as they mixed with other nations, failing to be a light of the One True God to them.
Consequently, the lived under the curses of the law. When Jesus died on the cross, the law system ended.
The law was abolished...canceled (Ephesians 2, Colossians 3).
The Book of the Law was permanently closed.
Why was the book of the Law permanently closed?
It was permanently closed because Jesus completely took upon himself the ultimate curse of the law, death (Deuteronomy 21:23), and in doing so set people free from the law (Galatians 3:13; 4:4).
Therefore, righteousness is not earned through the law...it never could be, but is a gift of grace received by faith in Jesus (Romans 3:21-25; 5:17; Galatians 2:21).
The law teachers who invaded the churches of Galatia where frightening the people, telling them if they did not obey the law, they would be under the curses of the law.
Consequently, the people were frightened back to the law.
Paul dealt with this issue in Galatians 3.
In response to these law teachers, Paul said if anyone communicated a different gospel other than the gospel of grace (by grace through faith in Jesus one is declared righteous), they were the ones under a curse.
This is because they were still seeking righteousness through the law and teaching others to do the same, when the law plainly says:
Cursed is everyone who does not continue to do everything written in the Book of the Law (Deuteronomy 27:16; Galatians 3:10).
Paul, then, in Galatians 1:8-9, emphatically writes:
But even if we or an angel from heaven should preach a gospel contrary to the one we preached to you, let him be under a curse! As we have said before, so now I say again: If anyone is preaching to you a gospel contrary to the one you embraced, let him be under a curse!
In writing this, Paul puts upon the law teachers what they were putting upon the people by telling the law teachers that if they pursued righteousness through the law (a different gospel) and taught others to do so, then they were the ones who would be cursed, because righteousness through the law required 100% obedience, with 100% of their hearts and minds, for 100% of their lives.
And no one can do this...including the teachers of the law.