Praise be to Allah, the Lord of the Worlds; and may His blessings and peace be upon our Prophet Muhammad and upon all his Family and Companions.
The Prophet (Sallallahu Alaihi wa Sallam) explained the wisdom behind the solar eclipse and lunar eclipse. He (Sallallahu Alaihi wa Sallam) 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.