Whether they were Jews, Gentiles, kings, magicians, astrologers or whatever, they brought gifts of gold, frankincense and myrrh, they last two of which were valuable and fungible commodities in their day and still are to this day.
Joseph, Mary and Jesus had to flee Judea and quickly, but just like people today, would not have had money to travel far off and get settled in a new and strange land.
God knew this well in advance, per the prophecies in Isaiah and Psalms. So he provided for the safety and economic sustenance of His Son in Egypt.......................