The reason they needed to rebuild Gezer was that the army of the king of Egypt had attacked Gezer and captured it. Then they had burned the houses in the city and killed all the people of the Canaan people-group who lived there. The king of Egypt gave that city to his daughter as a gift when she married Solomon.