Why were the Patriarchs refined through famine? So that their children would merit Torah. Abraham was refined through famine: "And there was a famine in the land, and Abram went down..." (Genesis 12:10). Isaac was refined through famine: "And there was a famine in the land, besides the first famine..." (Genesis 26:1). Jacob was refined through famine: "And Jacob saw that there was grain in Egypt, and he said, Behold, I have heard... that we may live and not die. And Joseph's brothers went down..." (Genesis 42:1, 3). David was refined through famine: "And there was a famine in the days of David three years..." (II Samuel 21:1).
Why the Patriarchs and David Were Refined Through Famine
Midrash Shmuel 28:2
מפני מה נצרפו האבות ברעבון, כדי שיזכו בניהם לתורה, אברהם נצרף ברעבון, ויהי רעב בארץ וירד אברם וגו' (בראשית י"ב י'), יצחק נצרף ברעבון, ויהי רעב בארץ מלבד הרעב הראשון וגו' (שם כ"ו א'), יעקב נצרף ברעבון, וירא יעקב כי יש שבר במצרים ויאמר הנה שמעתי וגו' ונחיה ולא נמות וירדו אחי יוסף (שם מ"ב ג'), דוד נצרף ברעבון, ויהי רעב בימי דוד שלש שנים וגו' (שמואל ב' כ"א א').