The mindset of legalism comes from distorting the purpose of God's commands to be for His benefit instead of for our benefit. This is a look at God's good intent in the commands He has issued. If we can have His mindset, then we will avoid being legalistic.