The short answer: water, fertile land and transport
Egyptians live near the Nile because it is the main dependable source of fresh water in a country that is mostly desert. The river also created the strip of fertile farmland where food can be grown, and it works as a natural route for moving people and goods. Away from the river and a few oases, life is much harder.
Almost no rain elsewhere
Most of Egypt receives very little rain. Without a river, farming across the country would be close to impossible, and drinking water would be scarce. The Nile brings water from far away, so even in the driest years there is something to draw on. For more on how the weather and the river fit together, see the Egyptian climate and the Nile River.
Fertile silt and farming
For thousands of years, the river’s yearly flood spread a layer of dark silt over the land beside it. That silt refreshed the soil, so farmers could grow crops such as wheat and barley, along with flax and vegetables, year after year without exhausting the ground. The strip of rich soil was known to the ancient Egyptians as the “Black Land.”
Today the Aswan High Dam controls the river, so the yearly flood no longer reaches Egyptian fields in the old way. Farmers now depend on irrigation canals and often use fertilizer, but the basic pattern is the same: farmland follows the water. If you are curious about the old cycle, see when did the Nile flood in ancient Egypt.
A highway through the desert
The Nile flows north, and winds in the region commonly blow from the north. In ancient times, boats could drift downstream with the current and sail upstream with the wind. This made the river an easy road for moving grain, stone, officials and armies along the length of the country. Travel across the surrounding desert was slower and riskier, so the river became the main artery of the kingdom.
Settlement patterns, then and now
Towns, temples and the capital cities of ancient Egypt were nearly all placed on or near the river or its branches in the Delta. Today the same pattern holds. The large majority of Egypt’s population lives in the Nile Valley and Delta, which together make up only a small share of the country’s land area. Cairo, Luxor and Aswan all sit on the river.
A few people live in desert oases, along the Red Sea and Mediterranean coasts, and in the Sinai, but the river valley remains by far the most densely settled part of the country.
Other benefits: fish, reeds and building materials
The river gave more than water and soil. It offered fish and waterfowl for food, papyrus reeds for making boats, ropes and writing material, and clay and mud for bricks. These resources made it practical to live there without importing everything.
This close link between a river and a society is often described as a river valley civilization. To explore the idea, read was Egypt a river valley civilization, and for a look at the land itself, see what type of geography does Egypt have.