Rabbi Abba bar Pappa said: Joshua was punished only because he caused Israel to neglect, for one night, the duty of being fruitful and multiplying, as it is said, "And he said, No" (Joshua 5:14) [understood as the angel's rebuke]. The captain of the host of the LORD said to him: Last evening you neglected the daily afternoon offering, and now you have neglected the study of Torah. Joshua said to him: For which of these have you come? He said to him: "Now I have come" (Joshua 5:14) [that is, for the present neglect of Torah]. Immediately, "Joshua lodged that night in the midst of the valley" (Joshua 8:9). Rabbi Yochanan said: This teaches that he lodged in the depths of the law. And it is an accepted tradition that as long as the Ark and the Divine Presence are not in their place, Israel is forbidden marital relations. And Rabbi Shmuel bar Abba said in the name of Rav: The study of Torah is greater than the offering of the daily sacrifices, as it is said, "Now I have come" [for the Torah]; and this refers to the study of Torah of the many, not of an individual.
Why Joshua Was Punished for One Night Without Torah
Yalkut Shimoni on Nach 15:16
א"ר אבא בר פפא לא נענש יהושע אלא על שבטל את ישראל לילה אחת מפריה ורביה שנאמר ויאמר לא וגו' שר צבא ה' וגו' א"ל אמש בטלתם תמיד של בין הערבים ועכשיו בטלתם תלמוד תורה. א"ל ועל איזה מהם באת א"ל עתה באתי, מיד וילן יהושע בלילה ההוא בתוך העמק. אמר רבי יוחנן מלמד שלן בעומקה של הלכה וגמירי כל זמן שארון ושכינה שלא במקומן ישראל אסורין בתשמיש המטה. וא"ר שמואל בר אבא משמיה דרב גדול ת"ת יותר מהקרבת תמידין שנאמר עתה באתי, ות"ת דרבים ולא דיחיד: