Feeling grateful to Allah for everything big and small is a part of faith, and a path to contentment. When we experience joy, or when something goes according to our wishes, or when our dreams come true, it is only natural that we praise Allah for it. And rightly so, for we feel His presence and His favour upon us. But sometimes there is more to it than meets the eye. Remember that ultimately this world and everything in it is a test. His tests do not only come during times of calamity, but in the form of fortune as well.
Knowledge before Taqwa
First comes knowledge. Wouldn't it be would be grossly inappropriate for a person to thank Allah for "successfully" committing a sin? Yet Muslims can be found thanking Allah (on social media on top of that) for their haram businesses and careers, or because they felt they "found the right one" in their haram relationships. While such matters have been normalised and may seem trivial, a sin is a sin and to feel gratitude towards Allah for it is odd.
Our moral compasses as human beings are subjective; we should always refer back to the Law if we were to lead moral lives. If it were to be offensive to hear someone thank Allah for stealing without getting caught or lying without being found out, then the same is said for such "normalized" or "harmless" sins.
Having knowledge of some Islamic fiqh is essential for a Muslim's life anyway, and any action one takes must be in line with the Shariah.
Taqwa before Gratitude
Naturally, after knowledge comes taqwa or God-fearingness. If the object of gratitude is known to be a sin, then one must abandon it and not feel thankful for it! For is being thankful in such cases like thanking for a portion of Hellfire!?
Also, intention is important. When Allah has bestowed upon us with one of His blessings, we should have intention to do right by it. He has granted us a favour, so what will we do with it? Will money be spent wisely or squandered away? Will we treat our spouses according to His law, or take them for granted? Gratitude becomes mere lip-service if it does not align with His commandments.
Human Nature
Allah has instilled in every human being - from His mercy - the instinctual response to feel gratitude for anything good that we experience in our lives. Naturally as Muslims, we feel grateful to Allah as we know Him to be the Possessor of all things and the Most Beneficent. But know that Allah's beneficence befalls on all of His creations, even upon those who disobey Him. Sometimes, even the thing that he blessed upon His creation becomes a means for their disobedience! Therefore, while to feel gratefulness to Allah is good in itself and a form of worship (as it includes His remembrance), know that it may not necessarily be from His love, but from His trials.
May Allah bless us with goodness that benefits us in both the dunya and the akhirah, amin.
~~~