The Catechism in Questions & Answers

281. With what attitude should human beings obey the commandments of God?

Those who recognise God in faith as the Almighty, Omniscient, and Loving One will inquire into His will, and will endeavour to align their thoughts and actions with the will of God, that is, in accordance with His commandments.
In the knowledge that God gave the commandments out of love for mankind, the commandments are not fulfilled out of fear of punishment, but out of love for God.