The whole book of Matthew focuses quite heavily on the fulfillment of prophecy. This is very clear in this second chapter. We see that in all aspects of his life Jesus fulfilled all of the prophecies pertaining to him beginning with his birth in Bethlehem.
There is another interesting aspect to this sequence of events as well. We saw that when Moses was alive he said that the Lord would raise up another prophet like him, from amongst their brethren (Deut 18:15-16, Acts 3:22-23). What we see is that there are many parallels between the lives of Moses & Jesus. For example, the rulers at the times of both their childhoods sought to kill all male children under the age of two. They were also both brought up out of Egypt. Moses was given the Old Covenant law to teach Israel and Jesus brought the New Covenant into effect to save the spiritual Israel. There are many other interesting similarities in their lives and again this strengthens the fulfillment of scripture and proof that Jesus is the Christ.