(Genesis 15:1:) "After these things the word of the LORD came to Abram." Let our master teach us: the burnt offering—on account of what did it come? Rabbi Ishmael says: on account of positive commandments and negative commandments. Rabbi Shimon ben Yochai says: on account of the meditation of the heart, as it is said (Job 1:5), "And it was, when the days of the feast had run their course, that Job would send and sanctify them," and so forth. You find that Abraham was reflecting upon the attribute of justice. What was he saying? Rabbi Levi said: it is as though he said, "It seems to me that I have received my reward in this world, for the Holy One, blessed be He, helped me against the kings and delivered us from the fiery furnace." The Holy One, blessed be He, said to him: "Since you have reflected upon Me, you must bring a burnt offering," as it is said (Genesis 22:2), "Take now your son," and so forth. Rabbi Isaac said: thus he was saying, "My heart utters gall and wormwood—perhaps among those whom I killed there were righteous ones." The Holy One, blessed be He, said to him: "Do not fear from this. They were thorns, and you bear no iniquity upon them but only reward," as it is said (Genesis 15:1), "Fear not, Abram, I am a shield to you; your reward shall be very great."
Why Abraham Brought a Burnt Offering After the War of Kings
Midrash Tanchuma Buber, Lech Lecha 13:1
אחר הדברים האלה היה דבר ה' אל אברם (בראשית טו א). ילמדנו רבינו העולה על מה היתה באה, ר' ישמעאל אומר על מצות תעשה ועל מצות לא תעשה, ר' שמעון בן יוחאי אומר על הרהור הלב, שנאמר ויהי כי הקיפו ימי המשתה וישלח איוב ויקדשם וגו' (איוב א ה). אתה מוצא אברהם היה מהרהר אחר מדת הדין, מה היה אומר, אמר ר' לוי כמדומה לי שקיבלתי שכרי בעולם הזה, שעזרני הקב"ה במלכים, והצילנו מכבשן האש, א"ל הקב"ה כיון שהרהרת אחרי, עולה אתה צריך להביא, שנאמר קח נא את בנך וגו' (בראשית כב ב), אמר ר' יצחק כך היה אומר לבי הוגה מרה ולענה, שמא אלו שהרגתי היה בהם צדיקים, א"ל הקב"ה מזה אל תירא, קוצים היו, ואין לך עליהם עון אלא שכר, שנאמר אל תירא אברם אנכי מגן לך (אף) שכרך הרבה מאד (שם טו א).