I recommend reading Empires of the Word by Ostler; it talks a lot about why some languages are replaced by conquest and others are resilient.
It boils down to the fact that it's actually very, very difficult to get a large population to change the language they speak at home. Simplistic histories often give some version of "X people conquered Y land and imposed their language," but that doesn't actually happen all that often. The language of the elite discourse, of politics and business, may change, but the vast majority of the populace, living out in scattered villages and rural areas, doesn't care how the elite in the capital talk.
Typically, conquerers will succeed in imposing their language on a conquered people in one of two ways: (1) they either displace or kill enough of the conquered that they become the majority of speakers, or (2) the languages that they and their subjects speak are very similar or even closely related, so that it's easy to adopt one or the other.
Native Arabs in the early years of Islamic expansion certainly weren't of sufficient numbers anywhere to make a majority (in fact, defining "Arab" as an ethnicity today is so controversial that most definitions are just "anyone who speaks Arabic natively"). So the first explanation is out.
Before Egypt, let's look at Syria (the greater Syria area, ancient Syria) and North Africa, both of which adopted Arabic fairly quickly. In both cases, there was an elite language spoken in the cities (Greek in Syria, Latin in North Africa), but the large majority of the population still spoke something else (Syriac/Aramaic and Punic). Greek and Latin both died fairly quickly after the conquest, because elite languages are very volatile and can rise and fall quickly -- but then the majority of the population in most areas adopted Arabic within a few generations. The reason is probably that Arabic is a Semitic language, and both Aramaic and Punic are also Semitic languages; they were all very similar to one another, so it was relatively easy to learn Arabic if you already knew Punic. (By contrast, Latin and Punic are nothing alike, which helps explain why Latin never took root among the majority of the population, despite the Romans having been there for around 600 years).
Coptic in Egypt is similar. It's not Semitic, but it's Afro-Asiatic, which is the overall family that Semitic languages belong to. It was apparently fairly easy to adopt Arabic if your native language was Coptic, and everyone who didn't have religious motives not to (i.e. what we now call Coptic Christians) did so.
Persian, meanwhile, has no relation to Semitic languages at all; it's in fact Indo-European, and is more closely related to English than to Arabic. That, and the fact that Persia was a large area that was very densely populated with Persian speakers meant that it was difficult for Arabic to make any headway there. (And for some speculation on my part: the fact that there was no diglossia in Persia, unlike North Africa where the elite spoke Latin and the common people spoke Punic, maybe gave the language some more stability and firmness as well.)
Still, it was a near thing. Arabic also had a religious impulse behind it, and for some time educated Persians were bilingual and often wrote in Arabic; but they never dropped Persian. After a little while written Persian (now written in Arabic script) asserted itself again as a language of culture with a rich history, and it even set itself up as a lingua franca against Arabic. The Seljuk Turks, for instance, primarily used Persian rather than Arabic as their official court language (though they knew some Arabic too, for religious reasons), and the Ottomans followed. In the middle ages, if you were a non-Arabic Muslim, there's a good chance you either knew Persian yourself or lived in an area where Persian was the lingua franca or elite language.