Reference: Majmoo’ Fataawa wa Rasaa.il Muhammad ibn Saalih al-‘Uthaymeen – Volume 16, Page No.298
Question: What is the reason behind solar and lunar eclipses?
Response: The Messenger (‘alayhis-salaatu was-salaam) has explained the reasoning, [which is] that Allaah wishes to alarm his servants with them [by way of a reminder to worship Him alone and to refrain from sins]; This is the reason which is befitting for the people to concern themselves with.
As for the actual physical reason, then that is [well] known; The reason for the lunar eclipse is that the Moon [passes] behind the Earth so that the Earth blocks the [rays of the] Sun [from striking the Moon]. [The lunar eclipse occurs] because the light (glow) of the Moon is derived from the Sun.
As for the reason for the solar eclipse, [then] that is when the Moon [passes] between the Sun and the Earth [whereby it fully or partially blocks the Sun as viewed from Earth].