Excerpt from "Behold a People" by R' Avigdor Miller, zt"l:
The growth of the nation was a spectacular phenomenon. "The children of Israel were fruitful and swarmed and increased and became powerful, very very much" (Shemos 1:7). The land began to fill up with them. They were all high-spirited and intelligent, and every family was animated by the noble traditions of the house of the Fathers. From the beginning, the new nation possessed prophets and sages, and had a senate of Elders (ibid 4:29). The sons of Zerach ben Yehudah: Ethan, Heiman, Calcol and Darda, all born in Egypt, were famous for their sagacity (1 Melachim 5:11) and were prophets (Seder Olam 20), and the people were skilled in every craft (Shemos 35:10). Their traditions were carefully guarded. "Yaakov .. set apart Levi and appointed him as a person of authority, and set him over an academy to teach G-d's ways and the precepts of Avraham. He commanded his sons to maintain an official from the family of Levi in every generation, so that the tradition should never be forgotten. This continued among the children of Yaakov and those who joined them, until there came into existence an entire nation which knew G-d" (Rambam, Avodah Zara 1:3).
"This continued for many years until finally some began to learn from the Egyptians, and worshiped their gods ... The family of Levi stood fast by the precepts of the Fathers and never served idols" (ibid.). This began after the passing of Yosef and his brothers, 80 years after they had entered Egypt. Yosef had reflected great prestige upon his family, and therefore many of his people became friendly with the people of the land. Some discontinued the practice of Circumcision (Shemos Rabbah 1:10) and behaved in some ways like gentiles, and there arose the danger of assimilation. G-d sent a prophet to warn them, as Yechezkel revealed 886 years later. "I made Myself known to them in the land of Egypt .. And I said to them: Let each man cast away the abominations ..., and do not defile yourselves with the idols of Egypt .. They rebelled against Me and did not consent to hearken to Me ... And I said I would pour out My wrath upon them" (Yechezkel 20:5-8). This prophet is hinted at elsewhere (1 Shmuel 2:27). Had the sinners hearkened, Israel could have fulfilled the prophecy of servitude (Bereishis 15:13) in peace and honor, just as Yosef had served Egypt for 80 years. Now, as always in Jewish history, G-d took action to prevent assimilation by causing the gentiles to become enemies. "He turned their heart to hate His people, to scheme against His servants" (Tehillim 105:25).
Related post: Does being anti-Israel mean one is anti Semitic?