17:104
And We said thereafter to the Children of Israel, “Dwell securely in the land (of promise)”: but when the second of the warnings came to pass, We gathered you together in a mingled crowd
Commentators explain that the account of Pharaoh is mentioned in this context because it closely parallels the situation of the polytheists (mushriks) of Makkah, who were attempting to drive the Prophet Muḥammad and the believers out of Arabia. The narrative serves as a warning: Pharaoh sought to uproot Moses and the Children of Israel, yet he and his followers were ultimately destroyed, while Moses and his people were established in the land. In the same way, the passage cautions the opponents of the Prophet that if they persist in similar hostility, they will face a comparable outcome
References:
Maududi, Abul Ala (2010). Tafhim ul Quran.