The eclipsed relationship
ויאמר אלקים יהי מארת ברקיע השמים להבדיל בין היום ובין הלילה והיו לאתת ולמועדים ולימים ושנים
G-d said: “Let there be luminaries in the sky to separate between day and night, and they will be for signs, set times, days and years”
On the fourth day of Hashem’s Six Days of Creation, we are taught that Hashem created what we know today as the Sun and the Moon. These celestial bodies, besides their other purposes, serve as practical time indicators. They’re used to distinguish between day and night, and to tell how far along it is during the day and night. As well, the Jewish Calendar is set up to rely on the lunar cycle, and the stage the Moon is in indicates how far along it is in the month. Many festivals occur during the full Moon, and the New Moon indicates the start of a new month. The Torah says that the luminaries are also for “signs”. What signs is the Torah referring to?
Rashi explains that the verse is referring to a teaching from Chazal: When the sun is afflicted, it’s a bad sign for the whole world. This is analogous to a King who made a feast for his servants and placed a torch for them to use as light. The King got angry at them and removed the torch, so they were left in the dark. This is commonly understood to be referring to solar and lunar eclipses. When the sun or the moon are blocked, it’s a bad omen. Many commentaries are bothered by the obvious question: How could these astronomical events be bad omens if they’re predictable? Scientists can tell you in advance when and where the next eclipse would be. Seemingly they should be no more an omen than if the Sun comes up tomorrow. How can we understand this teaching?
One possible explanation is that an eclipse, while being a natural phenomenon that occurs regularly, is really just a metaphor. It’s something for us to experience and learn from. The prophet Isaiah rebuked the nation by saying that their sins separate them from Hashem. It’s like they installed an iron barrier between themselves and their Creator. This is true, despite the fact that Hashem is constantly bestowing His Goodness to us. He never stops. However, the good that He sends cannot reach us, because of the barriers we’ve created between the Good and us. Because of this, evil and badness comes to the world.
This is all alluded to by an eclipse. A solar eclipse is when the Moon blocks the Sun, and a lunar eclipse is when the shadow of the Earth, caused by the Sun, blocks the Moon. This blockage prevents the light from reaching the Earth, even though the light is still emitted. This is what Chazal meant with their teaching. When the luminaries are afflicted, however it happens scientifically, this is a sign for us to contemplate. Why is there evil and badness in the world? Hashem is always bestowing His goodness upon us! It’s due to our sins, which block His good from reaching us.
 Based on Maharam Shik al HaTorah to Leviticus 1:1 s.v. ויקרא אל משה וידבר ה’ אליו מאהל מועד לאמר
 Genesis 1:14
 Ad. loc.
 Sukkah 29a
 It is subsequently taught there that Rabbi Meir says that if the luminaries are afflicted, it’s only a bad sign for the Jews (who are used to punishment). A subsequent baraisa teaches that if the Sun is afflicted, it’s a bad sign for the non-Jews (who use the sun for their calendar), whereas if the Moon is afflicted, it’s a bad sign for the Jews (who use the moon for their calendar). There are other specifications that aren’t addressed by the Maharam Shik
 For example: Maharal in Be’er HaGoleh 6:2 (he also explains why specifically the sins listed there would be the ones to “cause” the luminaries to be afflicted. See also note 9), Yearos Devash II § 12 (who suggests Chazal are referring to something similar to sun spots, not eclipses, although I’m not sure how it would apply to the moon), and Aruch LaNer ad. loc.,
 Isaiah 59:2
 The Maharam Shik seemed to have a different understanding of eclipses, as he says its when a כוכב blocks the Sun
 It’s not clear to me how the Maharam Shik’s explanation fits with the continuation of the gemarra, which proceeds to list specific sins which cause the luminaries to be afflicted. According to his explanation, nothing we do causes eclipses, as it’s just a message for us to contemplate every so often. As well, all sins should be relevant. Perhaps he’d understand “cause” to mean that if we never sinned, there would be no need for such a message through the luminaries. See Be’er HaGoleh loc. cit., who gives a similar explanation for the usage of the word “cause”