"And lest you lift up your eyes to heaven [and see the sun, etc.]" (Deuteronomy 4:19) — for they had not yet seen the sun nor the moon, because the cloud surrounded them. Moses said to them: You are destined to see the sun and the moon, but do not think that they are gods; rather, the Holy One, blessed be He, created them to give light upon the earth. And this is what is said, "which the LORD [your God] has allotted them" (to give light) "to all the peoples" (Deuteronomy 4:19) — who worship them. Even though you see that the Holy One, blessed be He, does not exact punishment from those gods, [saying,] "Since I do not destroy them, they have substance" — it is not so. Rather, He smooths them over with words, so that [the nations] will suppose that there is power in them to save themselves, and so that they will not depart from them, from worshipping them — in order to find their iniquity and to hate them.
Why Moses Warned Israel the Sun and Moon Are Not Gods
Midrash Aggadah, Deuteronomy 4:19
ופן תשא עיניך השמימה [וראית את השמש וגו']. שעדיין לא ראו שמש ולא ירח מפני שהענן מקיף אותם, אמר להם משה עתידים אתם לראות שמש וירח ואל תחשבו שהם אלוהות, אלא הקב"ה בראם להאיר על הארץ, וזהו שנאמר אשר חלק ה' [אלהיך] אותם (להאיר) לכל העמים, שעובדים להם אעפ"י שאתם רואים שאין הקב"ה פורע מאותן אלהות שאיני סותרם יש להם ממש, לא כן אלא מחליקן בדברים כדי שיהיו סבורין שיש בהם כח להציל עצמה, וכדי שלא יפרישו מהם מלעבדם, למצוא עונם ולשנוא אותם: