Greek was the language of government and the ruling elite in Egypt from the Ptolemies (successors to Alexander the Great in the fourth century BC) down to the conquest of Byzantine Egypt by Muslim Arabs in the seventh century AD, around 1000 years.
In 'Empires of the Word: A Language History of the World' by Nicholas Ostler the author considers why some languages of conquerors (e.g. Latin in France & Spain and Arabic in the Middle East) permanently become the language of the conquered country and others (e.g. Turkish in most of the former Ottoman Empire or Russian in Poland) did not.
He thought various factors were important, but two of particular relevance to Egypt included:
Size of population. Egypt (and China) have had long-running linguistic continuity, despite periodic invasions by outsiders, as their fertile river valleys have long sustained such dense populations that an incoming minority of foreign conquerors was more likely to be absorbed into the much larger native population, and eventually adopt their language, than vice versa.
It is easier for a population to adopt a language related in grammar, sounds and vocabulary to the one they previously spoke than a completely different one e.g. Latin could be relatively easily adopted by Gaulish Celtic speakers because they are related Indo-European languages. Ditto Semitic Arabic by Coptic Egyptians whose language while not technically Semitic was related to it, both, together with some other languages such as Berber, being part of what is called the Afro-Asiatic family of languages.
Applying these two tendencies (rules would be too strong a word for them, you can find exceptions, but I think they have some validity) the vast Afro-Asiatic language speaking Egyptian population was relatively unlikely to adopt the unrelated Indo-European language of the ruling Greek minority.
It was though more likely, although the process cannot have been that easy, as it seems to have taken nearly a thousand years to complete, for the Arabic of the next set of rulers to be adopted by the Egyptian speaking population.
For example, as far as I can say as a non-expert but having studied some Ancient Egyptian and tried to find out a little about Coptic, the language derived from Ancient Egyptian that was spoken by the mass of the Egyptian people at the time of the Arab conquest, Egyptian and Arabic both either often or normally have the sentence order Verb-Subject-Object (V-S-O). Ancient Greek normally used either S-V-O (like English) or S-O-V.
Egyptian & Arabic both include sounds made deep in the throat that do not exist in Greek, or any other European language to my knowledge, with the possible exception of the long-extinct and non-Indo-European language Etruscan.
Egyptian & Arabic both divided the nouns into 2 genders (masculine and feminine) while Greek has 3, (masculine, feminine and neuter).
Hence, it was easier for Egyptians to adopt a language like Arabic than to switch to speaking Greek.
This does necessarily exclude other factors that other people have mentioned also having some importance e.g. once Egyptians began converting to Islam, the importance and prestige of Arabic as the language of the Quran. However, against that, in the Christian period Greek must also have had importance and prestige as the language of the New Testament, but that never led to Greek becoming the language of the Egyptian people, as Arabic later did.