Most of the north African countries are in the desert zone where water is most precious thing. Most of the ancient civilisations emerged in river basins. Indus Valley civilisation, Mesopotamian civilisation etc are good examples of river valley civilisations. Nile made Egypt a fertile land and Egypt was known as 'Gift of Nile'. The desert people known as Badarians from various regions migrated to Egypt in search of good drinking water and water for irrigation. They found a fertile land in the Nile river basin and they began to settle there and a civilisation emerged there is known as Egyptian civilisation.
Because ...it was their main source of water and when it flooded each year it left behind silt and fertile land for farming
It's not like they would settle in the middle of the desert. Jeez.