The primary reason that fossil fuels are harmful to the environment is that their use produces large amounts of greenhouse gases. These gases cause heat to build up in the atmosphere and raise the average temperature of the planet. Fossil fuels also pollute the air when they're burned and may cause environmental damage when they're mined.
Fossil fuels include coal, gasoline, diesel fuel, propane and natural gas. All of these fuels were created as organisms decayed and released carbon-rich compounds into the surrounding soil and rock over thousands of years. Humans access these resources through a variety of means, including drilling deep holes and mining coal from pits. Additionally, a process called “fracking” is used to remove reserves that are otherwise difficult to access. Fracking injects high-pressured water into bedrock to free the oil and gas inside. If the chemicals from the process contaminate the water table, widespread environmental damage may occur.
In addition to the pollution of the air and creation of greenhouse gases, petroleum products can cause environmental damage when they're spilled into the environment. When this occurs in the ocean, the spilled oil can coat great swaths of the water surface, killing a high number of plants and animals.