At its heart, legalism is a desire to appear holy. It is trying to be justified before men and not God.