With the flatworms, having more structural integrity than previous organisms allowing vastly superior locomotion, multicellular life began expanding as it reached different ecological niches faster and further on Earth. It was much easier for them to move through the environment, getting and removing respiratory needs via diffusion through their flat bodies.
For all their advantages these diffusion-based animals still needed to be in the right environment to supply moment-to-moment needs. Hit a place without the right osmotic pressure, pH or lacking in needed sustenance and the organism cannot thrive, reproduce or stay alive.
So while they had distinct advantages over previous organisms in being able to manipulate the environment (through it) they also retained one of the disadvantages of their single-cell ancestors. They were still dependent entirely upon where they were physically situated and could not venture away safely. Any one of a number of aspects in the environment could destroy them and thus they were still at the mercy of the outside world.
Much like their protozoan ancestors, the worms evolved a way to shut out the negative aspects of the environment that made them susceptible to death by getting rid of diffusion and generating a more robust hard shell. Instead of a cell membrane or cell wall though, worms evolved tissues surrounding their already present endothelial cells forming an outer cuticle.
These more advanced worms, the Roundworms or Nematodes, also had to come up with a solution to diffusion respiration and so the body cavity or coelom ('sea lum') arrived. Unlike the flatworms who ate and excreted from the same hole, this new development meant the one-end-in and another-end-out digestive system arose.
While earlier organisms had layers of cell tissues on top of each other that did different things none of them were very far from the outside environment, these new worms had better integrity from the environment with their innards being protected by more robust outer shell of tissues, as it were.
The stage was now set for worms to explode all over the Earth as they now had a lot more control over what aspects of the environment could affect them while taking what they needed with them from place to place.
A temporary gradient of toxic-to-flatworms chemicals in the environment could be easily passed through with no real threat to future reproduction, they could feed with no need to manage in and out of the same hole and could more powerfully maneuver through the environment among their many advantages over flatworms.
The Roundworms Successfully Adapted to both their outer and inner environment. Internal management improved with better control over their own respiration, better digestive system, better muscles, and a stronger, more selective tissue interface between internal and external environments with the sensory apparatus to operate it all within the environment.
Multicellular life could finally stop being homebodies and move out on their own, free from the constraints of their ancestors. The diversity of animal life that brought us into being was finally on the march, slithering and crawling far out across the Earth.