Paul went to Jerusalem to discuss the Gospel with the apostles there. They all agreed that Gentiles did not have to be circumcised to be saved, in opposition to some who argued that believers must follow the law.
The apostles and elders in Jerusalem affirmed Paul’s teaching of the gospel of grace. God was working through all of them; those in Jerusalem preached to the Jews, while Paul and his team preached to the Gentiles.
The harmony of the Jerusalem Council of Acts 15 did not last long. Soon thereafter, the Apostle Peter (Cephas) shows favoritism to Jewish believers who teach that Gentiles must obey the law, which is a serious misrepresentation of the Gospel.
Paul continues his public rebuke, and reminds Peter of the truth of the Gospel. Obeying the law does not justify anyone before God. Only faith in Jesus justifies us before God.
We are dead to the law because we have spiritually died with Christ, and have been given a new life to live, where Christ lives through us.
Paul defends his gospel, the true gospel of Jesus Christ, to bring the Galatians back to understanding their faith. He continues to tell his testimony and ministry experiences to show his authority. On his second trip to Jerusalem, Paul met with the apostles there, and they had a council where they defended the gospel of grace and faith. Peter was very outspoken that salvation came to all people the same way—by grace through faith.
Some of the believing Pharisees attending the council wanted Gentiles to follow the law and become circumcised, but the council rejected this. In spite of what Peter said at the Jerusalem council, he later showed hypocrisy by avoiding fellowship with the Gentile believers because they did not keep Jewish religious rules. Paul publicly rebuked Peter, reminding him that the gospel is through faith in Jesus, and only through faith. It seems likely that the consensus reached at the Jerusalem council in the presence of Paul had been undermined, and Paul was having to defend the gospel of grace once again, when it ought to have been settled. But Paul willingly continues to defend the gospel in this epistle, for that is the ministry he was given from God.