Fossil fuels are essentially the stored energy left behind by organisms, mostly algae and vegetation that lived millions of years ago. The major fossil fuels – coal, oil and natural gas – are considered to be "non-renewable" because the rate at which society uses use them (mostly in the past 100 -200 years) is infinitely faster than the rate at which they can be renewed (millions of years). At the same time, our supply of fossil fuels seems to continually expand because of new discoveries of existing resources and constant technological advances in extracting these resources.
Renewable energy resources such as wind, solar, tide and wave power require only ongoing natural processes such as sunshine to produce power. Fossil fuels take eons to form and require specific geologic and environmental conditions that are different for each fuel type. One necessary condition for all fossil fuels, however, is the need for an anaerobic (oxygen-less) environment in which to form. 
Coal. Geologists believe that underground coal deposits formed about 250–300 million years ago, when much of earth was swampy and covered with thick forest and plant growth. As the plants and trees died, they sank under the earth's wet surface, where insufficient oxygen slowed their decay and led to the formation of peat. New forests and plant life replaced the dead vegetation, and when the new forests and plants died, they also sank into the swampy ground. With the passage of time, as more underground layers of dead vegetation began to accumulate, they became compressed, producing heat. The combination of these conditions gave rise to different kinds of coal, each with a different carbon concentration. The English geologist William Hutton (1798–1860) reached this conclusion in 1833 when he found through microscopic examination that all varieties of coal contained plant cells and were of vegetable origin. (2)
Oil and Gas. Geologists also view crude oil (also known as "petroleum") and natural gas as the products of compression and the heating of ancient organic materials over geological time. Petroleum literally means “rock oil,” from the Latin terms petra, meaning rock, and oleum, which means oil. Hundreds of millions of years ago when the earth was covered in oceans and lakes, the algae and plants that lived in these bodies of water would die and settle on the bottom. These organic remains were eventually covered by mud and sediment that blocked oxygen from reaching and decaying them further. (3) More layers of sediment were added and became thousands of feet thick--subjecting the strata of plant and animal remains to enormous pressure. That pressure, combined with the heat of the Earth, changed the organic mixture into petroleum and natural gas. Eventually, concentrations of natural gas migrated and became trapped in the rock layers like a sponge traps water. (4)
Oil and natural gas are often found in similar areas, but since natural gas can only be created through very high pressure, it is more abundant at lower depths where the pressure is higher (usually 1 to 2 miles below the Earth’s surface). (5)