All perfect praise be to Allah, The Lord of the Worlds. I testify that there is none worthy of worship except Allah, and that Muhammad, sallallaahu 'alayhi wa sallam, is His slave and Messenger.
The Prophet explained the wisdom behind the solar eclipse and lunar eclipse.
He said: “The lunar and solar eclipse do not happen due to the death of anybody, or due to him staying alive, but they are one of the evidences (proofs, signs…) of (the existence of) Allah. If you see that happening, remember Allah until that dears up.” [Reported by Bukhari and Muslim, and the wording is the wording of Muslim]
Therefore, by the eclipse, Allah wants to remind the people with His Power and Might and make them fear His punishment and force, to incite them to repent and return to Allah.
Allah knows best.