For Luther, Calvin and the commentators that have followed them, Paul combats the error of legalism and preaches the pure gospel of righteousness through faith alone until chapter 5 verse 13, at which point it is thought he takes a sharp turn and begins warning the Galatians about another error that can arise due to the gospel of grace: i.e. living sinfully because you are saved by grace (often called "license"). Paul, it is said, changes direction. Chapters 5-6 are no longer addressing legalism but license, and Christians need to watch out that they don't live sinfully lest they also forfeit salvation that way. To remain consistent with the gospel of grace, this is explained to mean that if you live sinfully it proves that you are not really a believer. Thus chapters 5-6 are about assurance: the evidence of salvation, which is a holy life.
It is unfortunate that Luther, Calvin, and so many commentators since them, failed to see that Paul was saying nothing of the sort. He wasn't turning to an altogether different error in chapter 5-6 than the one he had been dealing with beforehand. The entire book of Galatians is about legalism, and chapters 5-6 are no exception. Chapters 5-6 constitute the essential ethical argument for righteousness through faith alone against the false doctrine of righteousness through law. Paul is showing how walking by the Spirit (which means walking with your mind on the things of the Spirit--Romans 8:5--which things are Christ and the new creation--Colossians 3:1-4) actually produces a holy life, and that walking by the flesh (which means walking with your mind on the old creation--human effort attempting to fulfill the law for righteousness) is what produces the vile works of the flesh, which even the Galatians want to avoid. Paul hasn't changed direction at all.
It is such a shame that assurance of salvation has been sought for in our own selves and by the measure of our holy living, because this practically undercuts the power of the gospel to set us free from introspection and to give us joy and peace in the freedom of God's grace--the very thing that produces good works! Assurance, the apostle John tells us, comes only from faith in Jesus Christ, not from the holiness of our lives as is so commonly taught. Assurance is desperately needed by Christians in order to do any good works at all, for our assurance doesn't come from our works, but our works come from our assurance. And yet the very thing we need in order to do good works (assurance) is the very thing that so many tell us depends upon the doing of good works. And ironically, it is actually by evaluating our own good works that assurance is taken from us--and thus joy and peace are taken away, and consequently the doing of good works. Thus the secret of good works which Paul desires for us to see and experience in chapters 5-6 is completely nullified. This is what Christians have historically failed to understand.
Luther and Calvin definitely understood the gospel, and as a consequence of their preaching millions of people have been objectively set free and brought to salvation. But by their common oversights, these same Christians who have been saved because of their preaching have also been gripped by subjective bondage to the doctrine of assurance of salvation by works. We are left with a Church that is going to heaven, but that is struggling unnecessarily on the way there, and is being robbed of its joy, peace and power.
May the Church arrive at a true understanding of the book of Galatians, the doctrine of assurance, and the secret of good works.