Skeletons are often given credit for giving support to the rest of the body. We depend on our skeletons, without them we would be very blob like, and not able to move on our own. How is it then that an earthworm is able to move so efficiently with no skeletal structure? The answer lies in the concept of hydrostatic pressure.
Hydrostatic pressure is the pressure that exists in a fluid filled chamber, or a worms body. The worm's body resists compression when squeezed. The body of the worm has muscles on the outer edge than twist and pull the body into various shapes, the water allows this and prevents the worm from simply flopping around uselessly.
The earthworm's body has a bit more complexity than just a fluid filled sack with some muscles. The worm's body is segmented. These segments work independently and make the worm able to stretch out only a part of its body while using another part of its body to anchor itself.

Just in case you missed that day in science class.