Muslim tradition tells us that even during the life of Muhammad, the Qur'an was being recited in different "tongues" (i.e. dialects) [1] and this continued until the third Caliph Uthmân (d. 656) authorized the burning of all versions of the Qur'an that didn't match the copy he had, written in the Quraishi Arabic dialect [2]. Even if he's counted as one of the 4 Rightly-Guided Caliphs, Uthmân is closely related to the rulers known as the Umayyads (from Umayya, his great-grandfather) who are known for their nepotism [3]. By doing this, Uthman would start a tradition of favoring the Quraishi people and their dialect [4] which would continue during Umayyad rule (661 - 750). This would be the main reason why Arabic spread alongside Islamic conquest.
New conquered territory brought 'Ajams (non-Arabic speakers) under Muslim rule, and the appointed generals and governors of these lands despised indigenous languages imposed Arabic on the natives, sometimes violently [5]. By the time Caliph Abd Al-malik came to power (d. 705), the administration was centralized in Damascus and Arabic became the official language of the Empire [6]. This forced Arabization would lead to many revolts, some of them were successful, such as the secession of modern-day Morocco. The third Fitna (crisis) in 744 AD would be the start of the end for the Umayyads, and a major revolution started in Iran led by the Abbasids. After the Abbasid revolution and their takeover in 750 AD, things changed. First, the Abbasid were much more accepting of the cultures within their borders [7], even though Arabic remained the lingua franca. On top of that, the Abbasids will be threatened by the Mawâlis (former slaves) who were gaining more power than the ruling House in Baghdad, especially in Iran, and this would eventually lead to the takeover of the Ghurids (879 - 1215), Saffarids (861 - 1003), and Buyids (945 - 1055), who were much more accepting of Persian culture and language [8]. On the other hand, Anatolia, which was part of the Byzantine empire, would be conquered by the Seljuk Turks (1037 - 1194) who embraced Islam without using Arabic except in theology and science [9]. Their empire would be desintegrated and the Ottomans will take over Anatolia. Egypt, however, would be ruled by the Fatimids (909 - 1171) who used Arabic for the most part [10]. You can say that the spread of Arabic followed two trends: the first came about quickly and followed the spread of Islam, but indigenous populations resisted to the Arabization, which made the language limited to theology, law and science. By the time the Umayyad empire fell, a new wave of slow Arabization emerged as new Arabic dynasties continued their rule over Muslim territory, but also due to immigration of Arab tribes and their settlement in other territories [11].
.
.
.
.
Notes and references:
.
.
[1] Bukhâri 3047, Muslim 819 (Hadith compilations).
[2] See for example: Neuwirth, Sinai and Marx. The Qur'an in Context: Historical and Literary Investigations Into the Qur'an, p787.
[3] Ibrahim, Merchant Capital and Islam, p139.
[4] For example, the Muslim ruler had to come from Quraish and only the Quraishi dialect was the liturgical language.
[5] See the peotry of Al-Isfahâni, Kitâb al-Aghâni, vol. 4, p423. Or al-Bîrûnî, al-Âthâr al-Bâqiyah, p35-36. You also read also about Yusuf ibn al-Hajjâj al-Thaqafî, one of the most controversial military generals of the Umayyads.
[6] Robinson, Abd Al-Malik (biography).
[7] Hughes, Abrahamic Religions: On the Uses and Abuses of History, p136.
[8] The Ghurids even exported their Persian heritage to India. See Avari, Islamic Civilization in South Asia, A History of Muslim Power.
[9] See: Tezcan, Identity and Identity Formation in the Ottoman World: A volume of Essays in Honor of N. itzkowitz, p8.
[10] Cortese, Women and the Fatimids in the World of Islam, p189.
[11] See for example the history of the Hillali tribes.
Arabic did not fail to spread within the Ottoman Empire. Court writers were typically literate in Ottoman Turkish (a combination language made up of vulgar Turkish, Persian, and Arabic), Arabic, and Persian. This was not the case for every single person, of course, but the Topkapı Palace schools trained its students in these languages, as well as European languages for the diplomatic corps. In addition, much of the Ottoman elite was made up of people of Balkan ancestry who spoke those languages.
Locations like Egypt took more easily to Arabic because the region was heavily colonized by Arabs during the Islamic conquests in the High Caliphal period and after, which in many ways superseded the polyglot Roman-Egyptian-Greek culture that had been there. In Persia, Islam encountered a very ancient culture and tradition and there was exchange between the Arabic and Persian traditions. Persian became the literary language throughout the Islamic world, however, Arabic remained the dominant language of religious and intellectual discourse. The Turkic tribes maintained their own languages of course and their own religion. Relatively speaking, they were latecomers to Islam and therefore Arabic. The Ottomans did not adopt Arabic as their main language in part because of these reasons, and it was also a way to differentiate themselves from the Arabs and the Mamluk dynasty.
This language issue is also partly related to a controversy that existed early in Islamic history of whether Islam was for the Arabs or a universal religion. Early on, following the death of Muhammad, it was believed that Islam was the religion of the Arabic warrior class and not universal. This changed of course as time went on and there were more converts as people wanted to gain status within the Islamic order.
Overall, Arabic did not fail to spread to those areas you mentioned but it was a secondary language for the elite of Persia and the Ottoman Empire.