When you are thankful for something, or when you thank someone, and say, “You are so gracious and kind,” it helps you remember that people have been gracious and kind to you. When you feel that, you will be less lonely. When you say, “Thank you for the gift,” you will remember than you have been given things that you have wanted and needed, and you ill feel less abandoned. When you say, “Thank you, you are so helpful,” you not only know you have people who want to do things for you, you are inspired to be helpful yourself.
In this way, expressing gratitude is very selfish: you get to be aware of all the good things that have come your way.