"I call heaven and earth to witness against you this day." In every covenant they are witnesses for Israel, as you say: "The heavens shall reveal his iniquity, and the earth shall rise up against him" (Job 20:27). And "one witness shall not rise up against a man," but only "by the mouth of two witnesses" (Deuteronomy 19:15). Therefore, when Israel transgress the Torah, "He will shut up the heavens, and there shall be no rain, and the ground shall not yield her fruit" (Deuteronomy 11:17). And it says: "And I will make your heaven as iron, and your earth as brass" (Leviticus 26:19).
Heaven and Earth as Israel's Two Witnesses to the Torah
Midrash Aggadah, Deuteronomy 4:26
העידותי בכם היום את השמים ואת הארץ. בכל תנאי השמים והארץ הם עדים לישראל, וכמה דאת אמר יגלו שמים עונו וארץ מתקוממה לו (איוב כ כז), ועד אחד לא יקום באיש אלא על פי שנים עדים, א"כ כשיעברו ישראל את התורה, ועצר את השמים ולא יהיה מטר והאדמה לא תתן את יבולה (דברים יא יז), ואומר ונתתי את שמיכם כברזל ואת ארצכם כנחשה (ויקר' כ"ו י"ט):