The heart is a complex thing. We can agree with the truth, sing about the truth, even teach the truth — and still, when fear creeps in, reach for rules instead of trusting the gospel that God loves me.
We often think legalism is just insecurity between us and God. Galatians 2 shows that our relationships with people reveal places where the gospel is believed but not yet fully trusted.