u/cajunrouge has written a great response to a similar question.
Following the Muslim conquests, many local languages, such as Berber or Coptic, were gradually replaced with Arabic and turned into minority languages. What allowed Persian to not share the same fate?