Praise be to Allaah.
It is mustahabb to pray naafil prayers at all times, except at the times when praying is not allowed. These times are from after Fajr prayer until the sun has risen to the height of a spear; from noon time until after the sun has passed its zenith, which is at mid-day for about five minutes before the sun reaches its zenith; and from after ‘Asr prayer until the sun sets. What is meant is the prayer which each person does by himself; once he has prayed ‘Asr, it becomes haraam for him to pray until the sun has set, except in specific cases, when it is not haraam. See Question # 306.
The reason why it (prayer at these times) is not allowed is so as to avoid any resemblance to the kuffaar who prostrate to the sun when it rises as a greeting to it and to express their joy, and they prostrate to it when it sets as a farewell to it. The Prophet (peace and blessings of Allaah be upon him) was keen to put a stop to all things that may lead to shirk, or that might involve any resemblance to the mushrikeen. With regard to the prohibition on praying when the sun is near its zenith, this is because this is the time when the Fire of Hell is intensified, as was reported from the Prophet (peace and blessings of Allaah be upon him), so we should refrain from praying at these times.
Summarized from the fatwas of Shaykh Ibn ‘Uthaymeen, 1/354