This post will be short, as I only mean to make a quick and simple point.
Some people lump rules in almost any sense with legalism. Others count all rules beyond the clear moral law legalism. Both of these are misguided.
Properly speaking, legalism refers to two possible mistakes. The first error is about salvation. A deadly kind of legalism makes rules, whether God’s rules or man’s rules, a means of salvation. If we follow the rules, we can get to heaven, and if we break them, we run the risk of hell. This is obviously heretical. Salvation is sola fide and sola gratia, through faith alone and by grace alone. No amount of rule-keeping or rule-breaking can make or break our relationship to God. Christ takes care of that.
The second possible error is about Christian teaching. Legalism also can apply to declaring moral rules that simply aren’t from God as though they were. When we say that God condemns what He has never prohibited, or that God commands what He has never required, we are guilty of legalism. A common example of this kind of legalism is the idea that drinking alcohol is a sin. An example of the flip side is saying that God morally requires us to adopt certain particular political positions, like a carbon tax or a border wall. Where we cannot show from sound Scriptural interpretation or clear reason from nature what proves something necessarily right or wrong, it is legalism to make rules that God commands or forbids it.
So, I said at first that not all rules are legalism. What kinds of rules do I mean? These are rules which church or legal authorities make that don’t claim to affect your status before God or define His will. They have other reasons or explanations, like the common good or keeping order. Indeed, you can have tons of such rules without legalism as long as no one claims that they express God’s own judgment.
The upshot of all this? A church body or even a government can make rules that affect the Church without being guilty of legalism. Some of these we already accept without question. Setting service times and lengths are rules, but not the bad kind. Lots of other possible rules are, however different, of the same nature. Now, when you multiply rules over God’s people, there are lots of other ways to go wrong. But legalism isn’t necessarily one of them.