All perfect praise be to Allaah, the Lord of the worlds. I testify that there is none worthy of worship except Allaah and that Muhammad, sallallaahu ‘alayhi wa sallam, is His slave and Messenger.
We have not found any verse of the Quran or Hadeeth of the Messenger of Allaah, sallallaahu ‘alayhi wa sallam, regarding looking directly at the sun during a solar eclipse. However, if it is proven to have negative health effects, then it is forbidden.
As for the Hadeeth on solar and lunar eclipses, the Prophet, sallallaahu ‘alayhi wa sallam, explained the wisdom behind them. He, sallallaahu ‘alayhi wa sallam, said:
"The sun and moon are two signs among the signs of Allaah, the Exalted. They do not eclipse due to anyone's death or birth. So, when there is an eclipse, observe prayer and supplication till it (the sun or moon) brightens. (the eclipse is over)." [Al-Bukhari]
The version of this Hadeeth that was cited in Saheeh Muslim reads, "The sun and moon are two signs among the signs of Allaah, the Exalted, which He sends to frighten His slaves with…" [Muslim]
The circumstances and context in which this Hadeeth was narrated were that the sun eclipsed on the day when Ibraheem (the son of the Prophet, sallallaahu ‘alayhi wa sallam) died and the people said, "The sun has eclipsed because of the death of Ibraheem." The Prophet, sallallaahu ‘alayhi wa sallam, clarified that the significance of a solar eclipse is to frighten the people (from disobeying their Lord) just like Allaah Almighty frightens them with other signs such as strong winds, earthquakes, and volcanoes.
Allaah Knows best.