To get to the other side?
No- it's not just because of the waste - that's why you get pools of foam on the top of still water. If you mean why does it foam when water breaks etc- then it's because the water mixes with the air when it folds over- a bit like when you fire a hosepipe into a pond or someting- you'll see lots of airbubbles travelling back up to the surface.
Even clean sea or river water will foam when splashed about by current or waves.
This is because it has various natural chemicals in it -- probably alginates from floating single-celled plants. Alginates are sugar-based compounds similar to starch, some of which are used (from larger seaweed) as stiffening agents in foods such as ice cream.
Richard