In Matthew 2:13-23, Joseph is told in a dream to go to Egypt because King Herod wanted to kill him.
If you recall the story of the Magi, they were originally sent by Herod as well, but they avoided him instead of telling him where Jesus was. Herod was jealous that there would be another king rising up among the people, which is why he wanted Jesus dead. So Joseph moved to Egypt to protect his family.
Joseph was warned in a dream to take the young child and his mother and flee to Egypt untill he hears from God again. (Matthew 2.13) So "the holy family" that fled to Egypt, were Joseph and Mary and Jesus.
Actualy Mary and Joseph fled only once to Egypt from king Herod.
Mary , Joseph and the baby Jesus fled in the night to Egypt.
The angel who instructs Joseph to flee to Egypt is identified in the Gospel of Matthew. After the visit of the Magi, an angel appears to Joseph in a dream, warning him of King Herod's plans to kill the child Jesus. Following this divine guidance, Joseph takes Mary and Jesus and escapes to Egypt to ensure their safety.
Joseph and Mary fled with the baby Jesus to Egypt, as the angel told Joseph to flee as the king Herod wanted to kill all the babies.
God did in a dream.
Here Jesus was not warned to flee, but the angel warned Joseph in a dream.
EgyptMat 2:13 Now when they had departed, behold, an angel of the Lord appeared to Joseph in a dream, saying, "Arise, take the young Child and His mother, flee to Egypt, and stay there until I bring you word; for Herod will seek the young Child to destroy Him."
Jesus escaped to Egypt from Bethlehem, not Nazareth. King Herod, who wanted to kill him, ordered the massacre of all infant boys in Bethlehem, prompting Joseph and Mary to flee to Egypt with Jesus to keep him safe.
If you mean Mary, the mother of Jesus, she was a refugee because they had to flee to Egypt so that Herod would not find and kill Jesus.
After the wise men came to visit Jesus, there was the necessity for Joseph, Mary and Jesus to flee into Egypt to escape the wrath of Herod. It is quite reasonable to assume that they needed the gold to pay for expenses in this foreign land. bascilly they gave it to chariety
Matthew 2 13And when they were departed, behold, the angel of the Lord appeareth to Joseph in a dream, saying, Arise, and take the young child and his mother, and flee into Egypt, and be thou there until I bring thee word: for Herod will seek the young child to destroy him.