Wastewater treatment involves the collection and cleaning of dirty water from the sewers. This water comes from the flushing of toilets, through drains and from factories. Water engineers design treatment plants which remove the contaminants from the dirty water. Contaminants might include sewage, toilet paper, bacteria, chemicals and other things which people put down the drains or which come from factories or in the water which is washed of the land into the rivers. Once the wastewater treatment processes have taken place, clean water remains which can then be sent back to the rivers and sea.
This episode of the BBC series, Come Outside, explains the process of wastewater treatment really clearly https://www.youtube.com/watch?v=L6cvrGLgIZY.