(Numbers 23:1:) And Balaam said to Balak, "Build for me here [seven altars]," etc. Why seven altars? Corresponding to the seven righteous ones who built seven altars, from Adam until Moses, and were accepted: Adam, Abel, Noah, and Abraham, and Isaac, and Jacob, and Moses. And he [Balaam] said: Why did You accept these? Was it not on account of the service they performed before You that You accepted them? Is it not fitting for You that You be served by seventy nations, and not by a single nation? The Holy Spirit answered him (Proverbs 17:1): "Better a dry morsel with tranquility in it than a house full of feasts of strife." Better a meal-offering mixed with oil, or dry, than a house full of feasts of strife — for you wish to introduce strife between Me and the children of Israel.
Why Balaam Built Seven Altars and Heaven Refused His Bargain
Midrash Tanchuma Buber, Balak 16:1
ויאמר בלעם [אל בלק] בנה לי בזה וגו' (שם כג א). למה שבע מזבחות, כנגד שבעה צדיקים שבנו שבע מזבחות, מאדם עד משה ונתקבלו, אדם הבל נח ואברהם ויצחק ויעקב ומשה, ואמר למה קבלת את אלו, לא בשביל עבודה שעבדו לפניך קבלתם, לא נאה לך שתהא נעבד משבעים אומות, ולא מאומה אחת, השיבו רוח הקודש טוב פת חריבה ושלוה בה מבית מלא זבחי ריב (משלי יז א), טובה מנחה בלולה בשמן וחריבה, מבית מלוא זבחי ריב, שאתה רוצה להכניס מריבה ביני ובין בני ישראלף.