A body cavity is an aspect of a number of basic animal body plans (phyla) that incorporate a central body cavity, known as a coelom. The coelom contains major organs, including the digestive system, heart, kidneys, etc. The coelom has two openings for the input of food and ejection of waste. It is filled with liquid that acts as a lubricant allowing the visceral organs to move freely relative to one another.
The most common body plans for large mobile animals fall into a group called the Bilateria. They include the annelids, arthropods, chordates, vertebrates, echinoderms, and mollusks. All have a cavity known as a coelom -- presumably inherited from a common ancestor. They are divided into two groups based on whether the first opening in the coelom cell wall during development of the animal becomes the anus or the mouth. In protostomes, the opening becomes the mouth. Protostomes include annelids, arthropods and mollusks. In Deuterostomes, the opening becomes the anus. Chordates and echinoderms are both Deuterostomes.
In arthropods and mollusks, the coelom is reduced in size, and the principal body cavity is part of the blood circulation system called a haemocoel .
The coelom may be subdivided into "subcavities" such as the pericardial cavity around the heart. The number and placement of these divisions are useful in the classification of, for example, the vertebrates.
These relatively obscure details are important to evolutionary theory. It is presumed that the bilateria evolved from a single common ancestor, and that the division between protostomes and deuterostomes represents an early step in that evolution. Since fossil evidence from that remote period is fragmentary and not always helpful, the analysis of animal development provides additional clues to the evolution of multi-celled animals. The origin of the coelom is unknown. It has been proposed that it developed within a group of organisms known as acoelomates via some members of another group known as "pseudocoelomates". Alternatively, it is thought that the coelom may have evolved from gastric pouches ("stomachs" sort of) in cnidarians.
http://www.gwu.edu/~darwin/BiSc151/Coelom/Coelom.html Further discussion.