Soil is a mixture of organic matter, minerals, gases, liquids, and organisms between a planet's atmosphere and lithosphere. A healthy soil was required to support life on a planet, and soil condition was one of the factors the Federation evalulated when considering where to settle populations. (DS9 episode: "Sanctuary")
Plant seeds were planted within soil. Obtaining nutrients and water from the surrounding soil the plants would grow up through the ground and up in to the air.
Great care had to be taken in importing seeds from other planets to ensure that they were compatible with the soil. A tragic example of what could go wrong was when seeds from Epsilon Sorona II were planted in the soil on Tarsus IV. The incompatibility of the seeds and soil spawned an exotic fungus that destroyed much of the Federation colony's food supplies. In the aftermath of the infection and subsequent massacre scientists such as Doctor Thomas Leighton redoubled their efforts to ensure there was never a repeat of the events of the Tarsus IV crisis. (DSC novel: Drastic Measures)
The Cardassian occupation of Bajor left much of the soil on the planet in a toxic condition. In the years following the liberation of Bajor soil reclamators were used to remove poisons and other toxins from the soil so that farmers could grow food in the soil once again. (DS9 episode: "Shakaar")