The apostle Paul says in Galatians 3:1-3:
"You foolish Galatians, who has bewitched you, before whose eyes Jesus Christ was publicly portrayed as crucified? This is the only thing I want to find out from you: did you receive the Spirit by the works of the Law, or by hearing with faith? Are you so foolish? Having begun by the Spirit, are you now being perfected by the flesh?"
The Christians in Galatia were wondering whether they needed to be circumcised to be saved. So some of the Gentile (non-Jewish) Christians were getting circumcised. But these verses tell us that we should not seek to be "perfected by the flesh".
Our salvation is not based on the works we do, because none of our good works can cancel any bad deeds or thoughts we have had. Our salvation is also not based on whether we are circumcised or not. Furthermore, our salvation is not based on keeping the works of the Law (e.g. sabbath, type of food we eat, etc.).
Our salvation is based on what Jesus, the perfect Son of God, did for us on the cross. He died to save us from our sins. When we believe in Jesus, we repent of our sins and take His righteousness upon us. We are righteous before God the Father because of Jesus' righteousness, not our own righteousness.
The Galatian church believed in Jesus and received the Holy Spirit. But then they thought they weren't saved until they were circumcised. So Paul warned them: "And I testify again to every man who receives circumcision, that he is under obligation to keep the whole Law. You have been severed from Christ, you who are seeking to be justified by law; you have fallen from grace." (Galatians 5:3-4)
Furthermore, Paul said, "You observe days and months and seasons and years. I fear for you, that perhaps I have labored over you in vain." (Galatians 4:10-11)
So the Galatians thought their salvation came from their own flesh (circumcision) and their own works (observance of all the Mosaic law). They forgot that their salvation came from faith in Christ. No one is perfected by the flesh. And no one can keep the Law perfectly. If we depend our hope on our own ability to keep the Law, we can't be saved because we are flawed human beings. But if we depend our hope on Jesus, who is perfect, we have blessed assurance.
There is a nuance here that should be noted. Paul continues on to say:
"Now the deeds of the flesh are evident, which are: immorality, impurity, sensuality, idolatry, sorcery, enmities, strife, jealousy, outbursts of anger, disputes, dissensions, factions, envying, drunkenness, carousing, and things like these, of which I forewarn you, just as I have forewarned you, that those who practice such things will not inherit the kingdom of God. But the fruit of the Spirit is love, joy, peace, patience, kindness, goodness, faithfulness, gentleness, self-control; against such things there is no law. Now those who belong to Christ Jesus have crucified the flesh with its passions and desires." (Galatians 5:19-24)
While our salvation is not based on our own good works, but on Christ's payment for our sins on the cross, we should be careful to truly repent and be true Christians. What this means is to not purposefully continue in sins, because the one who willfully continues to practice the sins listed above are lip-service believers and not true believers.
True believers are the ones who have decided to give up these fleshly passions and desires, and follow the Holy Spirit's leading. Those who truly believe will grow in love, peace, joy, goodness, and other fruits of the Spirit, while continuing to distance themselves from sins.