The Derech Hashem (2:3:10) writes
מקרים לאדם מצד גלגול נשמתו: עוד שורש אחר נמצא להנהגה בעניני העה״ז והוא
שהחכמה העליונה סידרה להרבות עוד ההצלה כמ״ש שנשמה אח׳ תבא לעה״ז פעמים
שונות בגופים שונים ועי״ז הנה תוכל לתקן בפעם א׳ את אשר קלקלה בפעם אחרת
או להשלים מה שלא השלימה ואולם בסוף כל הגלגולים לדין שלע״ל הנה הדין
יהיה עליה כפי כל מה שעבר עליה מן הגלגולים שנתגלגלה ומן המצבים שהיתה בם
Afflictions to a man from the reincarnation of his soul: There is [yet] another principle found in the direction of the matters of this
world. And that is that the Supreme Wisdom arranged to expand
salvation more, as we have mentioned, such that one soul comes to this
world at various times in different bodies. And behold through this,
it may repair at a different time what it corrupted in a [previous]
time; or perfect what it did not perfect. However at the end of all
the incarnations in the judgement in the future to come, the trial
will surely be regarding [the soul], according to all of the
incarnations that it experienced and all the states in which it
We are here to repair ourselves and our world using all the resources, talent, etc. at our disposal. If we don't succeed at first, we might return to this world to try fixing ourselves and our world again under different circumstances. Then we might return yet again after another failed attempt. During Krias Shema Al Hamita, we are forgiving anyone who has harmed us in any way, whether in this lifetime or a previous one. Why? When another is punished on our account, we too suffer some of the consequences. Chazal say one cannot be mekabel pnei haShechina while others are punished on their account. We don't wish that on ourselves, and we don't wish that damage on the world - whether in our current lifetime or previous ones, because they are all intertwined.
Moreover, the Mishna Berura (239:9) adds that forgiving those who harmed you will grant you a long life - גם ראוי למחול לכל מי שחטא כנגדו וציערו ובזכות זה האדם מאריך ימים. Following the Gemara Megillah (28a) listing why each individual merited a long life:
וְלֹא עָלְתָה עַל מִטָּתִי קִלְלַת חֲבֵרִי כִּי הָא דְּמַר זוּטְרָא
כִּי הֲוָה סָלֵיק לְפוּרְיֵיהּ אֲמַר שְׁרֵי לֵיהּ לְכׇל מַאן
דְּצַעֲרָן Rabbi Neḥunya also said: Nor did I ever allow the
resentment caused by my fellow’s curse to go up with me upon my bed.
This is referring to conduct such as that of Mar Zutra. When he would
go to bed at night, he would first say: I forgive anyone who has vexed
With that premise in mind, we aspire to forgive others from previous gilgulim each night because some of the tests we faced today may very well have been a rerun of a failed test in a previous lifetime. For instance, if Reuven sideswiped your wagon in the 1800s but didn't pay, and you didn't forgive him since the damage was never renumerated, then if he's granted the opportunity to fix what he broke once again, you and Reuven will come back in the 2000s and he might sideswipe your car. Maybe he'll fail the test once more and decide to hit-and-run. It's now up to you to forgive this person. You certainly don't have to, but you might come back again in the 2050s and he'll sideswipe your hover car all over again. Since we never know which of today's tests are "new episodes" or "reruns" from a previous lifetime, it's wise to forgive everyone who harmed us each day. Helpful for them to finally be let off, but most helpful for us not to need to return all over again.