"And the Lord said to Moses: Stretch out your hand toward the heavens (etc.)" (Exodus 9:22). This is what Scripture says: "Whatever the Lord desired He did (etc.)" (Psalms 115:3). The Holy One, blessed be He, said: "The heavens are the heavens of the Lord (etc.)" (Psalms 115:16). To what is the matter comparable? To a king who decreed and ordered concerning the people of Rome that they not go down to Syria, and that the people of Syria not go up to Rome. So too the Holy One, blessed be He: at the time when He created [the upper beings He said], "The heavens are the heavens of the Lord, [and the earth He gave to the children of man]" (Psalms 115:16). And when the Holy One, blessed be He, sought to give the Torah to Israel, He annulled the first decree, and said: Let the lower ones go up to the upper ones, and let the upper ones come down to the lower ones; and I am the one who begins, as it is said: "And the Lord came down upon Mount Sinai" (Exodus 19:20), and it is written: "And to Moses He said: Come up to the Lord (etc.)" (Exodus 24:1). Thus "whatever the Lord desired He did [in the heavens and on the earth]." When He wished, He said, "Let the waters be gathered" (Genesis 1:9), and when He wished, He made the sea into dry land, as it is said: "And the children of Israel walked [on dry land] through the midst of the sea (etc.)" (Exodus 14:29).
Why God Lifted the Decree Between Heaven and Earth at Sinai
Midrash Tanchuma Buber, Vaera 19:1
ויאמר ה' אל משה נטה [את] ידך על השמים וגו' (שמות ט כב). זש"ה כל אשר חפץ (ה') עשה וגו' (תהלים קטו ג), אמר הקב"ה השמים שמים לה' וגו' (שם שם טז), למה הדבר דומה, למלך שאמר וגזר על בני רומי שלא ירדו לסוריא, ובני סוריא לא יעלו לרומי, כך הקב"ה בשעה שברא [העליונים אמר] השמים שמים לה' [והארץ נתן לבני אדם] (שם), וכשביקש הקב"ה ליתן תורה לישראל, ביטל את הגזירה הראשונה, ואמר התחתונים יעלו לעליונים, והעליונים ירדו לתחתונים, ואני הוא המתחיל, שנאמר וירד ה' על הר סיני (שמות יט כ), וכתיב ואל משה אמר עלה אל ה' וגו' (שם כד א), הוי כל אשר חפץ ה' עשה [בשמים ובארץ], כשביקש אמר יקוו המים (בראשית א ט) וכשביקש אמר ועשה את הים יבשה שנאמר ובני ישראל הלכו [ביבשה] בתוך הים וגו' (שמות יד כט).