(Numbers 22:6:) "Perhaps I shall be able to smite them" (the verse there). What reason did this one have to provoke them to battle? Did not the Holy One, blessed be He, say to them that they were not to take from their land? Rather, it was that he was a master of sorceries and divinations more than Balaam, for thus it is written concerning him, "And Balak saw" (Numbers 22:2)—except that he did not direct the matters to their true meaning. And so it says, "You are wearied with your many counsels; let now those who divide the heavens, who gaze at the stars, who make known at the new moons, stand up and save you from what shall come upon you. Behold, they are like straw," etc. (Isaiah 47:13-14). And he saw that Israel would fall by his hand; therefore he made his daughter ownerless, and through her twenty-four thousand fell. For this reason he provoked them, but he did not know how. "Perhaps I shall be able to smite (nakkeh) them"—just as one discounts (menakkeh) one out of twenty-four in a se'ah; and thus there fell from Israel twenty-four thousand less one. (Explanation: twenty-four times twenty thousand is forty-eight myriads, and twenty-four times five thousand is twelve myriads. It turns out that if twenty-five thousand is found—that is one twenty-fourth of sixty myriads—yet only twenty-four thousand fell, behold, one thousand is lacking.)
Why Balak Sent His Daughter and the 24,000 Who Fell
Midrash Tanchuma Buber, Balak 6:3
אולי אוכל נכה בו (שם). מה ראה זה להתגרות בה, לא כך אמר להם הקב"ה, שלא נוטלים מארצם, אלא שהיה בעל נחשים וקסמים יותר מבלעם, שכך כתיב בו וירא בלק, אלא שלא היה מכוין הדברים לאמיתם, וכן הוא אומר נלאית ברוב עצתיך יעמדו נא ויושיעוך הברי שמים החוזים בכוכבים מודיעים לחדשים מאשר יבואו עליך הנה היו כקש וגו' (ישעיה מז יג יד), והיה רואה שישראל נופלים בידו, לפיכך הפקיר את בתו ונפלו בה כ"ד אלף, לכך נתגרה בהם ולא היה יודע היאך, אולי אוכל נכה בו, כמו שמנכה אחד מן כ"ד בסאה, וכך נפלו כ"ד אלף מישראל חסר אחד, (פי' כ"ד פעמים כ' אלף הם מ"ח ריבואות, וכ"ד פעמים ה' אלפים הם י"ב ריבואות, נמצא שאם נמצא כ"ה אלף זהו חלק כ"ד מס' ריבוא, ולא נפלו כי אם כ"ד אלף, הרי חסר אלף אחד).