"Do not reject the Egyptian completely because you lived in his land. Children who are born to them in the third generation may enter the congregation of Hashem" (Ki Teitzei 23:8-9). Rashi explains that although the Egyptians drowned the Jewish children in the river, the halacha is that Egyptian converts are permitted to marry into the Jewish people after the second generation because the Egyptians hosted the Jews in their time of need. When Yaakov Avinu and his family came down to Mitzrayim to escape the hunger of Eretz Cana'an, Pharoh allowed them to settle in the land. They were given food and housing and were initially treated with respect. For that, we owe the Egyptians a debt of gratitude, and as a token of our appreciation, the Torah permits Egyptian converts from the third generation and on to marry into the Jewish people.
At first glance, this halacha seems puzzling. For well over a century, the Egyptians were terribly cruel to the Jewish people. They enslaved and tortured and killed so many Jews. Why should we treat the Egyptians favorably for the small kindness they did when they persecuted us for generations?
Rav Pam commented that this halacha teaches an important lesson, that a small measure of good is not discounted by a large measure of evil. Although the Egyptians did oppress the Jewish people mercilessly, we are not allowed to overlook the generosity they initially displayed because every small kindness a person does should be recognized and appreciated even if most of the time he does not act properly. How much more so, said Rav Pam, should we show gratitude to someone who is generally kind and helpful, but once in while does something that aggravates us. After all, we want Hashem to remember all of our good deeds and overlook our occasional failures. We should treat other people the same way.
This idea that we should be thankful for every small kindness others do for us is relevant in our relationship with Hakadosh Boruch Hu as well. The Torah warns that the punishments of the tochacha will come "because you did not serve Hashem with joy and goodness of heart, when everything was abundant - meirov kol" (Ki Savo 28:47). On a simple level, the phrase meirov kol means when you had an abundance of good. But the Chasam Sofer suggested homiletically that perhaps it means when most of what you had was good. In other words, the Torah is saying that even when a person is frustrated by some things in life, if he counts the blessings Hashem has given him, he will realize that so much of it is good, and that appreciation should motivate him to want to serve Hashem to the best of his ability.
The Ramchal writes (Mesilas Yesharim, ch. 8) that the way for a person to acquire the middah of zerizus - feeling a passion for mitzvos - is by contemplating the many blessings Hashem has bestowed upon him. Every person has something to be thankful for, and that feeling should inspire him to want to fulfill Hashem's will scrupulously. Later (ch. 18), Ramchal explains that an even higher middah than zerizus is the middah of chassidus, when a person's love for Hashem is so great that he will not be satisfied with just fulfilling his mitzvah obligations, but rather he will search for opportunities to bring pleasure to Hashem - v'oseh nachas ruach l'yotzro - to follow the will of Hashem even without an explicit command. This middah as well, says the Ramchal (ch. 21), is best acquired when a person considers all the kindness and mercy Hashem has shown him. When a person thinks of Hashem's boundless affection for him, the natural reaction should be to want to "give back" - like a loving son would act toward a doting father - to behave in a way that brings pleasure to Hashem.
Rav Moshe Feinstein comments (Darash Moshe, p. 95) that this is the deeper meaning of the roshei teivos of the name Elul - ani l'Dodi v'Dodi li. The month of Elul is a time for teshuva. But the focus of Elul should not be limited to making amends for specific aveiros. Rather, Elul is a time to forge a new relationship with the Ribbono Shel Olam. It is a time to realize that Dodi li - Hashem has given us so much - and our response should be ani l'Dodi, that we want to give back, to dedicate ourselves to Torah and mitzvos with a renewed sense of passion and commitment.
The prospect of engaging in a meaningful process of teshuva might seem daunting, but the best place to start is by feeling a sense of gratitude for all the blessings we have.