Another interpretation. Rabbi Dostai said: If you took a wife and she bore a child and died, do not remain in your old age without a wife. Why? "Because you do not know which will prosper" (Ecclesiastes 11:6). From whom do you learn this? From Abraham, who in his youth begot only one, but in his old age begot twelve. Rabbi Levi said: This is what the Holy One, blessed be He, said to him: "And in you all the families of the earth shall be blessed" (Genesis 12:3) — for God rose up in the generation of the dispersion and scattered from them thirty families, as it is said: "And the LORD scattered them" (Genesis 11:8). Rabbi Levi said: The Holy One, blessed be He, said: From you I will establish them. This is what the Holy One, blessed be He, said to him: "And in you they shall be blessed" — and He established from him thirty families. And these are they: the twelve princes whom He established from Ishmael, and the sixteen sons of Keturah, and "two nations are in your womb" (Genesis 25:23) — behold, thirty families. Hence: "And Abraham took another wife" (Genesis 25:1).
Why Abraham Remarried in Old Age and Fathered Thirty Families
Midrash Tanchuma Buber, Chayei Sara 8:2
ד"א א"ר דוסתאי אם נטלת אשה וילדה ומתה, אל תשב לך בזקנותך חוץ מאשה, למה כי אינך יודע אי זה יכשר, ממי אתה למד מאברהם שבנערותו לא הוליד אלא אחד, ובזקנותו הוליד י"ב, אמר ר' לוי הוא שהקב"ה אמר לו ונברכו בך כל משפחות האדמה (בראשית יב ג), שעל אלהים בדור הפלגה והפיץ מהם שלשים משפחות, שנאמר ויפץ ה' אותם וגו' (שם יא ח). אמר ר' לוי אמר הקב"ה ממך אני מעמידן, הוא שהקב"ה אמר לו ונברכו בך, והעמיד ממנו שלשים משפחות, ואלו הן י"ב נשיאים שהעמיד מישמעאל, ושש עשרה בני קטורה, ושני גוים בבטנך הרי שלשים משפחות, הוי ויוסף אברהם ויקח אשה.