From The Gospel of Matthew, by Curtis Mitch and Edward Sri, commenting on Matthew 2:13-15, 19-23
Egypt was a fitting place for the holy family to flee to. In the first century Egypt was under Roman rule but outside Herod’s jurisdiction. It was a traditional place of refuge for the Jews (1 Kings 11:40; 2 Macc 5:8; Jer 26:21; 42:13–44:30), and there was a large Jewish population there, especially in Alexandria.
More broadly, this account of a wicked pagan tyrant killing the male children and of Jesus escaping death by Joseph and Mary fleeing to Egypt cannot help but recall the story of Moses and the exodus. Just as Moses was protected from Pharaoh’s plot to kill the Hebrew male children, so Jesus was saved from Herod’s massacre of the male children by divine intervention. Furthermore, Egypt played a role in both Moses’ and Jesus’ escapes from death. Moses grew up in an Egyptian household, which protected him from Pharaoh’s wicked decree, while Jesus was taken by his family to Egypt to avoid Herod’s violence.
This correspondence with Moses’ childhood tells us something important about Jesus’ future: the infant Jesus experiences divine protection from the evil rulers of this world because he, like Moses, is destined to save the people of Israel. Indeed, as Matthew already noted, Jesus will “save the people from their sins” (1:21).
The account of the flight to Egypt also links Jesus with Israel’s exodus from Egypt. Here we find Matthew’s second fulfillment quotation, Hosea 11:1: Out of Egypt I called my son. This passage looked back to the founding of the nation, when God called his firstborn son, Israel, out of slavery in Egypt (Exod 4:22; Hosea 11:1). Matthew views it typologically as pointing forward to this occasion when God rescues his beloved son Jesus from the tyrant Herod and later brings him out of Egypt (2:21).