Robert Krulwich has a good post about the origin of 90% (yes, 90%!) of the coal on Earth. It seems that back during the Carboniferous Period the fungi needed to break down "wood" hadn't evolved yet when "trees" started making cellulose and lignin. Because of that, the wood piled up and was eventually converted to coal by pressure and heat. Oh, and by the way, those "trees" are they same ones we find in the Mazon Creek fossil biota.
So imagine, then, these stands of towering, fernlike plants mostly growing in swamps. The air is warm and moist, and the land (Europe, the Americas, and Africa were at the time one continuous mass) is covered by millions—no, billions—of trees that are sucking carbon from the air, growing, aging, dying, falling, and releasing oxygen. This is a world littered with dead trees piling on top of each other.
But when those trees died, the bacteria, fungi, and other microbes that today would have chewed the dead wood into smaller and smaller bits were missing, or as Ward and Kirschvink put it, they “were not yet present.”
Bacteria existed, of course, but microbes that could ingest lignin and cellulose—the key wood-eaters—had yet to evolve. It’s a curious mismatch. Food to eat but no eaters to eat it. And so enormous loads of wood stayed whole. “Trees would fall and not decompose back,” write Ward and Kirschvink.
Instead, trunks and branches would fall on top of each other, and the weight of all that heavy wood would eventually compress those trees into peat and then, over time, into coal. Had those bacteria been around devouring wood, they’d have broken carbon bonds, releasing carbon and oxygen into the air, but instead the carbon stayed in the wood.