Rabbi Pinchas and Rabbi Yirmiyah in the name of Rabbi Chiyya bar Abba: Is not "lying down" itself death? Rather, because David died upon his bed, "lying down" is written of him; but because Joab was slain, "death" is written of him. Another interpretation: Is not "lying down" itself death? Rather, because David was a king, "lying down" is written of him; but because Joab was a captain of the army, "death" is written of him. Another interpretation: Is not "lying down" itself death? Rather, because David was anointed with the oil of anointing, "lying down" is written of him; but because Joab was not anointed with the oil of anointing, "death" is written of him. And when Joshua was born, no creature felt it, but when he died all Israel felt it. This is what is written, "And they buried him in the border of his inheritance... on the north side of the hill of Gaash" (Joshua 24:30). Rabbi Berechiah and Rabbi Simon in the name of Rabbi Yehoshua ben Levi: We searched through all of Scripture and did not find a place named the hill of Gaash. And what is "the hill of Gaash"? It teaches that Israel were lax in performing kindness with Joshua bin Nun, and the Holy One, blessed be He, sought to make the whole world quake upon its inhabitants, because Israel were busy with their work — this one busy with his vineyard, and this one busy with his field, and this one busy with his charcoal — therefore they did not perform kindness with Joshua. When Samuel died, what is written there? "And Samuel died, and all Israel gathered together and lamented him..." (1 Samuel 25:1). Rabbi Yehoshua ben Levi said: The proverb says, "One whom a serpent has bitten is frightened by a rope." Rabbi Shmuel bar Nachman said: To Samuel they gave from his own, because it is written, "And he went year by year..." (and it is written) "and his return was to Ramah, for there was his house, and there he judged Israel" (1 Samuel 7:16-17).
Why David Lay Down but Joab Died and the Quaking of Mount Gaash
Midrash Shmuel 23:7
רבי פנחס ורבי ירמיה בשם רבי חייא בר אבא ולא שכיבה היא מיתה, אלא דוד על ידי (ששכב) [שמת] על מטתו, כתוב בו שכיבה, ויואב על ידי שנהרג כתוב בו מיתה. דבר אחר ולא שכיבה [היא מיתה], אלא דוד על ידי שהיה מלך כתוב בו שכיבה, ויואב על ידי שהיה שר הצבא כתוב בו מיתה. דבר אחר ולא שכיבה היא מיתה, אלא דוד על ידי (שלא נמשח) [שנמשח] בשמן המשחה כתוב בו שכיבה, ויואב על ידי שלא נמשח בשמן המשחה כתוב בו מיתה. וכשנולד יהושע לא הרגיש בו בריה, וכיון שמת הרגישו בו כל ישראל, הדא הוא דכתיב ויקברו אותו בגבול נחלתו וגו' מצפון להר געש (יהושע כ"ד ל'), רבי ברכיה ורבי סימון בשם רבי יהושע בן לוי חזרנו על כל המקרא ולא מצינו מקום ששמו הר געש, ומה הוא הר געש, מלמד שנתעצלו ישראל מלעשות חסד עם יהושע בן נון, ביקש הקב"ה להרעיש את כל העולם כלו על יושביו, לפי שהיו ישראל עסוקין במלאכתן, זה עסוק בכרמו, וזה עסוק בשדהו, וזה עסוק בפחמו, לפיכך לא עשו חסד עם יהושע, כיון דמית (שאול) [שמואל] מה כתב תמן, וימת שמואל ויקבצו כל ישראל ויספדו לו וגו' (שמואל א' כ"ה א'), אמר רבי יהושע בן לוי מתלא אמרי דנכית בחיויא חבל מדחיל ליה, אמר ר' שמואל בר נחמן שמואל משלו נתנו לו, לפי שכתב והלך מדי שנה בשנה וגו', (וכתיב) ותשובתו הרמתה כי שם ביתו ושם שפט את ישראל (שמואל א' ז' ט"ז-י"ז).