Background
Paul wrote this letter to the church in Galatia after he found out that they had fallen into error. A group of false prophets had infiltrated the church and preached a message that salvation is earned by obeying the laws of Moses. Paul had to write a letter to refute this and bring the Galatian church back on the right path.
Saved by grace through faith and not by obeying the law
Gal 2:16 know that a person is not justified by the works of the law, but by faith in Jesus Christ. So we, too, have put our faith in Christ Jesus that we may be justified by faith in Christ and not by the works of the law, because by the works of the law no one will be justified.
Gal 5:3 Again I declare to every man who lets himself be circumcised that he is obligated to obey the whole law. 4 You who are trying to be justified by the law have been alienated from Christ; you have fallen away from grace.
This is the most serious threat a church can face. To have doctrines penetrate the church that will cause the members to go on the wrong road to salvation. Paul reminded them that salvation is a free gift to those who believe. We can never earn it with our good deeds by obeying the commandments. If we rely on our own effort to gain salvation, we forfeit it altogether.
Law does not save us but that does not mean we lead careless lives
On one extreme are those that believe that it is necessary to keep the law to earn salvation. Paul had told them that this is not correct. At the other extreme is the belief that since the law cannot save, it is totally irrelevant and we can live our lives as we like. Paul had to refute this as well. It does not mean that the law has no benefit whatsoever. The law makes us aware of sin and it can serve as a guide on how we live. The law is also centred around how we should love one another and we cannot stop loving one another.
Gal 5:13 You, my brothers and sisters, were called to be free. But do not use your freedom to indulge the flesh; rather, serve one another humbly in love. 14 For the entire law is fulfilled in keeping this one command: “Love your neighbor as yourself.” 15 If you bite and devour each other, watch out or you will be destroyed by each other.
Anyone who thinks that they can get away with careless living will eventually reap the effects of a sinful life.
Gal 6:7 Do not be deceived: God cannot be mocked. A man reaps what he sows. 8 Whoever sows to please their flesh, from the flesh will reap destruction; whoever sows to please the Spirit, from the Spirit will reap eternal life.