It is narrated from Uqbah ibn Amir al-Juhani: "The Messenger of Allah (peace be upon him) forbade us from praying or burying our dead during three times: when the sun begins to rise until it is fully up, when the sun is at its height at midday until it passes the meridian, and when the sun draws near to setting until it sets." (Muslim, Salat al-Musafirin, 293 [831]; see also Abu Dawood, Tatavvu', 10 [1277]; Janaiz, 55 [3192]).
Islam prohibits worshipping anyone other than Allah or any behavior that may resemble such actions. The prohibition or dislike of performing prayers at specific times should be understood in this context. These times coincide with the worship times of Zoroastrians.
The restriction on praying during these times aims to prevent Muslims from resembling fire-worshippers. This also helps in developing a distinct identity and worship consciousness among Muslims.