One of the companions of the prophet had said "There were three times at which Allah's messenger(saw) used to forbid us to pray or bury our dead.
1. When the sun began to rise until it was fully up.
2. When the sun was at it's height at midday till it passed the meridian,
3. When the sun drew near to setting till it had set." (MUSLIM)
These are the times the sun worshipers prayed and so to be different and not be mistaken as one of them, we were forbidden to pray at this time.
FORBIDDEN TIMES FOR NAFL PRAYER
(i) Abu Sa'eed al Khudree(ra) reported Allah's messenger(saw) as saying, "No prayer is to be said after the 'Fajr' prayer until the sun rises, or after the 'Asr' prayer until the sun sets."(Bukhari & Muslim)
Only 'nafl' prayer is forbidden at these times but a missed 'fard' prayer can be offered. Most of the ulamas of the Muslim Ummah allowed the offering of missed 'fard' prayer after 'Fajr' and 'Asr' because of the following hadith ; Prophet Muhammad(saw) said, Who has forgotten the prayer he should pray it whenever he remembers it." (Bukhari & Muslim)
(ii) A 'nafl' prayer cannot be offered once the Iqamat for 'fard' prayer has been said. Abu Hurairah narrated that the messenger of Allah(saw) said, "When the Iqamat has been said, then, there is no prayer valid (Nafl or sunnat) except the 'Fard' prayer for which the Iqamat was said." (Ahmad & Muslim)