We have long desired to live in an environment free of human waste, initially because of the foul smell, and later, once we made the connection, to prevent serious and deadly outbreaks of disease. Sewer systems fit the bill by transporting large amounts of human excrement away from populated areas, and they have been evolving for thousands of years.
Between 2000 and 4000 B.C.E., the Mesopotamian Empire (modern-day Iraq), Mohenjo-Daro (modern-day Pakistan), Egypt, the island of Crete and the Orkney Islands in Scotland already had drainage systems -- and, in some cases, indoor sanitation facilities. By a few hundred years B.C.E., the Greeks had sewer systems that transported rain and wastewater to collection basins that irrigated and fertilized fields. The ancient Romans had underground sewers that fed into the Tiber River.
There was a lot of trial and error through the years, with disease outbreaks pointing out the need to keep sewer outlets away from drinking water. Over time, we also learned of the need to maintain the sewers, and the manhole was born (or re-invented, as we'll see later). Most were also constructed to be periodically flushed out with tidewater or rainwater.
From ancient times to just a few decades ago, sewers mainly transported raw waste directly to rivers, oceans or other large bodies of water. Modern sewer systems are more complex, leading to sewage treatment plants where the water is treated via filtration and addition of various chemicals to disinfect and remove contaminants before it's returned to nature. And no doubt they will continue to evolve.