Why did Paul write the epistle to the Galatians?
It is important to understand the overarching theme of Galatians in order to gain greater insight to its content and Paul's purpose in writing it. Paul wrote to address the tension that had risen between the law and the gospel, Jew and Gentile, God's old-covenant people and His new-covenant people.
Paul's major concern in writing this letter is to address the instruction of the Jewish Christians who had come after He and Barnabas left them. He is prepared to do battle with anyone who claims anything that is either apart from or in addition to Christ, to be necessary for salvation. He was trying to communicate his understanding of this issue according to his understanding of the gospel. God had promised salvation to the world first through Abraham and Israel, but it would ultimately come to realization through a divine mediator in the person and work of Jesus Christ.
The gospel is a message of unity. Salvation had come and in order to further this gospel, this good news of God's grace, it was essential that believers be united through this message of hope and in a common faith in Jesus Christ.