O people, worship your Lord who created you and those that were before you, so that you may be fearful.
Worship (ʿibāda) is becoming harmonious (muwāfaqa) with the command and it is pouring all energy into requests for realization (taḥqīq) of the unseen. The declaration of oneness (tawḥīd) enters one through the heart, disengagement (tajrīd) [enters] through the innermost self, becoming single-minded (tafrīd) [comes] through intention (qaṣd), and humility [comes] through the self. Surrender (istislām) is to the decree (ḥukm).
It is said, “worship Him” by renouncing prohibited things, persevering in performing acts of obedience, welcoming obligatory acts with humility and lowliness, and avoiding detours through the waystations of laziness and indifference.
His saying “so that you may be fearful” is to bring the command closer to them and to make it easier. By the word “may” He keeps them at the bounds of fear and hope.
The real meaning of “fear of God” (taqwā) is protecting oneself through conformity [to God's command] from the threats of punishment.