Mt 2:13-16
Pharaoh, king of Egypt, feared that the people of Israel would prosper, so he ordered that if an Israelite woman gave birth to a boy, the child should be killed. But God protected the coming of Christ. (Ex 1:15-22)
Ex 1:15 And the king of Egypt spake to the Hebrew midwives, of which the name of the one was Shiphrah, and the name of the other Puah: 16 And he said, When ye do the office of a midwife to the Hebrew women, and see them upon the stools; if it be a son, then ye shall kill him: but if it be a daughter, then she shall live. 17 But the midwives feared God, and did not as the king of Egypt commanded them, but saved the men children alive. 18 And the king of Egypt called for the midwives, and said unto them, Why have ye done this thing, and have saved the men children alive? 19 And the midwives said unto Pharaoh, Because the Hebrew women are not as the Egyptian women; for they are lively, and are delivered ere the midwives come in unto them. 20 Therefore God dealt well with the midwives: and the people multiplied, and waxed very mighty. 21 And it came to pass, because the midwives feared God, that he made them houses. 22 And Pharaoh charged all his people, saying, Every son that is born ye shall cast into the river, and every daughter ye shall save alive.
When King Herod knew that Christ was born, he killed the children who were born to kill Christ. However, God made the Joseph family flee to Egypt to protect Christ who was born. (Mt 2:13-16)
Mt 2:13 And 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. 14 When he arose, he took the young child and his mother by night, and departed into Egypt: 15 And was there until the death of Herod: that it might be fulfilled which was spoken of the Lord by the prophet, saying, Out of Egypt have I called my son. 16 Then Herod, when he saw that he was mocked of the wise men, was exceeding wroth, and sent forth, and slew all the children that were in Bethlehem, and in all the coasts thereof, from two years old and under, according to the time which he had diligently inquired of the wise men.