Ga 3:2 This only would I learn of you, Received ye the Spirit by the works of the law, or by the hearing of faith? Ga 3:6 ¶ Even as Abraham believed God, and it was accounted to him for righteousness
The word “legalism” (sometimes used in a negative light) is not in the bible, the concept simply refers to keeping a law, Mt 5:17.
Jesus summarized the Law of God as Love for God and neighbor. The Law of Moses teaches a person that a sacrifice is necessary to obtain forgiveness of sins, Rm 10:4.
Under the New Covenant Christians have to confess sin to the sacrifice (Jesus), for forgiveness.
In this way the law us leads to Christ, Gal 3:24. Christ is the end or goal of the law.
Ro 10:4 For Christ is the end of the law unto righteousness to every one that believeth
Abraham believed (had faith in) God and was considered righteous – he did the right thing, 1 Jn 3:7.
Doing the “works of the Law” is not the right way to be made acceptable to God, even though the sacrifices had to be made for a person to be forgiven after they sinned in the Old covenant, Heb 10:8. They could have sacrificed forever but without faith in God it would not have been the right way to be acceptable to God.
Ga 5:4 Ye are severed from Christ, ye would be justified by the law; ye are fallen away from grace.
God’s grace teaches a person to deny ungodliness. The law of Moses however taught a person to be reconciled to God after they sinned by appealing to God through a sacrifice.
Jesus is the sacrifice under the New Covenant.
Many times people think they can be right with God by doing what they consider to be right in their own eyes or estimation. Doing what is right is insufficient unless it is accompanied by faith in God.
Ro 9:30 What shall we say then? That the Gentiles, who followed not after righteousness, attained to righteousness, even the righteousness which is of faith: Ro 9:31 but Israel, following after a law of righteousness, did not arrive at that law. Ro 9:32 Wherefore? Because they sought it not by faith, but as it were by works. They stumbled at the stone of stumbling;
Heb 10:8 Saying above, Sacrifices and offerings and whole burnt offerings and sacrifices for sin thou wouldest not, neither hadst pleasure therein (the which are offered according to the law), (ASV)
Heb 10:10 By the which will we are sanctified through the offering of the body of Jesus Christ once for all.