In order that you remember and perform all My commandments (Numbers 15:40).
Memory is a unique Divine gift. Indeed, to this very day, neuropsychologists have not discovered the secret of exactly how memory operates. The turnover of the chemicals in our bodies is such that after a period of time not a single atom remains in the brain that was there several months earlier, yet a person's brain retains memories for years, decades, a lifetime.
This unique gift should not be abused. Many times the Torah tells us what we should remember and cautions us against forgetting. The concepts and events that we must retain are goals that are vital to our spiritual well-being. Most siddurim list six verses of the Torah that we should recite each day to remind us of who we are and to caution us against idolatry and lashon hara (harmful talk).
However, if we use this wonderful gift to remember those who have offended us and to harbor grudges against them, or if we remember the favors we have done for others and expect them to be beholden to us, we are abusing this Divine gift.
The key to discerning what we should remember and what we should forget is contained in the above verse: "In order that you remember and perform all My commandments." Any memory that does not assist us in working toward the ultimate goal of serving God does not deserve being retained.