Gratitude is the practice of focusing on the good things you have in life.
Focusing on the good things provides input to your reticular activating system which results in you noticing more good things.
Focusing on the good things results in your brain noticing opportunities that will create more of those good things. This becomes a cycle that builds on itself.
Life is perception and what you focus on determines your perception.