See the fundamental danger of legalism is not living with rules or not living by rules—whether you attend church every week or not, whether you drink wine or not. Legalism points to a much deeper heart issue....
At its most dangerous level, legalism is a soteriological problem. That is, legalism is a false gospel and a false hope. Legalism is the lie that says God’s pleasure and joy in me is dependent upon my performance rather than the finished work of Christ....Believers equally bring pleasure to God because the pleasure He receives in us is the purchased pleasure of the substitution of Jesus Christ. Any imagined superiority to other Christians (not rules or a lack of rules) is the sure sign of the legalist.
The great irony (and danger) of legalism is this: If you think God is more pleased with you because you take your child to a soccer game instead of church, if you think God is more pleased with you because you do not live by rules, and if you think God is more pleased with you because you do drink alcohol—you are just as legalistic as the man who thinks that perfect church attendance, lists of rules, and abstaining from alcohol makes him more pleasing to God.
Rules are not the problem.
Tim Keller's book The Prodigal God makes a strong case that we need to learn to repent not only from our sins but also from out righteousness. The statement above shows that we must also repent from our legalisms - both positive and negative.
It's really all about Jesus, His work His grace, His righteousness.