After Matthew records the departure of the young Jesus to Egypt (a fulfillment of Hosea 11:1), the massacre of the infants in Bethlehem, and finally the death of Herod; an angel appeared to Joseph to return with the child and His mother back to Israel.
However, Joseph was afraid to return to Judea because the son of Herod, Archelaus was reigning the place of his father. Apparently Joseph’s fear was legitimate as God warned him in a dream about the danger there, and Joseph instead turned to Galilee.
The city of Nazareth was where Joseph settled, and where Jesus was raised. In fact, he was often referred to and known as Jesus of Nazareth in the New Testament. Nathanael, in John 1:46 asked about Jesus, “Can anything good come out of Nazareth?” Indicating the city did not have a good reputation in Israel at the time.
This was also a fulfillment of a prophecy concerning the Christ. “He shall be called a Nazarene”, which was written hundreds of years previously, in Judges 13:5.