The Talmud states that this folk saying is related to the Torah commandment, "Do not reject an Egyptian, because you were a dweller in his land" (Deuteronomy 23:8). Since Egypt hosted the Israelites, we, their descendants, must acknowledge our gratitude.
The brief period of tranquility that our ancestors enjoyed in Egypt was followed by decades of ruthless enslavement and brutal oppression. Thousands of newborn Israelite children were murdered. This unspeakable horror more than obscured any favorable treatment they had received earlier, and our natural inclination is to despise the Egyptians with a passion.
The Torah tells us to take a different path. Although we celebrate, every Passover, our liberation from this tyrannical enslavement and commemorate the triumph over our oppressors, we have no right to deny that we did receive some benefit from them. Even though a denial of gratitude might appear well justified in this particular case, it might impact upon us in such a manner that we might also deny gratitude when it is fully deserved.
If people cast stones into the well from which they drank, the well will not be hurt in the least, because it is an inanimate and insensitive object. The act, however, might impact negatively upon those who do it: they might subsequently behave with a lack of gratitude to people as well.