Amalek’s War Was a Punishment for Bittul Torah:
The pasuk states (Shemos 17:8): “And Amalek came and he fought with Yisroel in Refidim.” The Ohr Hachaim Hakadosh explains this to mean that Klal Yisroel were punished for not engaging sufficiently in the “milchamto shel Torah”. Since Torah is compared to both fire and water, they were punished with thirst and with the fire of war with Amalek.
The pasuk continues to say that Moshe told Yehoshua: “Choose for us men and go to fight Amalek.” Since Moshe knew that the war with Amalek was a result of bittul Torah, he knew that Yehoshua was the one who could fight the battle, as he was “the man who never left the tent” (ibid 33:11), meaning that he learned Torah all day. He told him to choose men like himself who were fully engaged in Torah study, as only they could win this battle.