Paul penned the book of Galatians because church members in Galatia were turning away from the true gospel and had embraced a false one (Galatians 1:6-7). Early on, Paul had to establish his credentials - that the gospel he preached did not have its source in any man, as Gnostic ideas do, but had come directly from Jesus Christ (verses 11-12). The Galatians were returning to the "weak and beggarly elements" (Galatians 4:9), referring to the demonism they had been involved in prior to their conversion (verse 8). The Gentile Galatians were observing certain days, months, seasons, and years that had nothing to do with God's holy days (verse 10), but were part of a system that elevated rites and ceremonies above the sacrifice of Jesus Christ, even while paying lip service to Christianity.
Paul addresses a philosophy that venerated the Torah - and went so far as to teach that one could be justified by works of the law - but also involved astrology and receiving revelations from angels (Galatians 1:8). Because of the belief that the spirit of a person was trying to get back to heaven, worship of angels and astrology was a common tenet of Gnosticism, since angels and the patterns of stars and planets were believed to hold keys to this spiritual journey. Contrary to popular assumption, Paul does not condemn God's law in Galatians but a corrupt system that was severely affecting the church. That Gnostic system happened to include an emphasis on the Old Covenant at the expense of Jesus Christ's life, death, and teachings.
Gnostic Christians borrowed the idea of redemption through Christ, but rather than believing that He redeemed them from sin, they believed that He would redeem them from matter - that is, from the flesh, which they considered to be inherently evil. At the core of Gnosticism is the belief that knowledge, typically secret knowledge - knowledge from angels, from the stars and planets, from the ancients - was the path to holiness and salvation. They believed that the path of redemption was through knowledge, and that the worst evil was ignorance.
Thus, they did not endeavor to overcome sin but ignorance. If they could just become wise enough, they reasoned, sin would not be a problem because they would be more spiritual than physical. Obviously, they overlooked man's incurably sick heart (Jeremiah 17:9), and the struggle that a person must undertake to overcome it. The Gnostics believed that the solution was found in greater understanding, rather than in a Savior and High Priest who justifies and guides us through a process of sanctification. In essence, Gnostics would rather learn than submit.
What is more, the knowledge that the Gnostics sought always originated in something other than God and His Word. We know that knowledge itself is not the problem. In the Bible, knowledge is generally presented as a good thing. God goes so far as to say that Israel is "destroyed for lack of knowledge" (Hosea 4:6). However, the knowledge He means is the knowledge of Himself and of His way of life, not knowledge as an end in itself.
In the New Testament, Paul tells the congregation at Rome that Israel has "a zeal for God, but not according to knowledge" (Romans 10:2). Israelites like to think they are serving God, but the way they go about it is contrary to the instructions that God gave them. Jesus Himself says that eternal life is to know God and Jesus Christ (John 17:3), by which He means the experience of an intimate relationship with the Father and the Son, something the Gnostics would never accept. They believed that a spiritual and thus pure God would have nothing to do with what they considered to be entirely evil matter and flesh. They did not care that God called His physical creation "good" - even "very good" - for they still saw it as corrupt, a prison from which to be liberated.