King Herod discovered the wise men had tricked him by not returning with the information he requested. Herod was furious, so he had every male child (two years or younger) in Bethlehem killed.
This was a fulfillment of Jeremiah’s prophecy, “A voice was heard in Ramah, weeping and loud lamentation, Rachel weeping for her children; she refused to be comforted, because they are no more.” (ESV)
King Herod refused to study the scriptures and lived according to his own evil desires. However, a part of him must have feared the scriptures were true. Why else would he put so much effort into killing a baby?
After Herod died, an angel of the Lord appeared to Joseph in Egypt. The angle told Joseph, “Rise, take the child and his mother and go to the land of Israel, for those who sought the child’s life are dead.” (ESV)
Joseph took his family to Israel, but he was still afraid. Archelaus, the son of Herod, was now the king in Judea. Joseph had a dream and he was told to go to the district of Galilee.
Joseph and his family moved to Nazareth and this was also a fulfillment of prophecy. Jesus Christ was to be called a Nazarene.