Why are sedimentary rocks the only rock type to contain fossils?
Well, as you know, there are three types of rocks. There are
Let's think about all of them and why some can contain fossils, but the other can't. But first of all, what is a fossil?
Fossils are organic products which are preserved in the Earth's crust. This means that the fossil is usually formed on or under (but not too deep!) the Earth's surface or under the water.
In other words in the biosphere (think about the biosphere limits). Then this organic material is covered by debris and etc. and becomes the fossil material.
Now, the igneous rocks, these rocks are usually formed from extremely hot magma deep inside the crust or with severe (not always) lava explosions. Obviously, magma and lava can't contain any life forms because they come from the deepest and hottest places on the Earth where life is impossible. That's why fossils can't be found in the igneous rocks.
The metamorphic rocks also can't contain any fossil as you'll see below. How does the metamorphic rock form? Simply the igneous rocks (which CAN NOT originally contain any FOSSILS) or the sedimentary rocks (which CAN originally contain some FOSSILS) undergo extremely high pressures or/and temperatures.
But in these conditions, the structure of the rocks, even if they originally contained some organic material, will be altered.
Finally, the sedimentary rocks are the one type which can contain fossils because these rocks are formed on the Earth surface, under the water, at very low temperatures and pressures. In other words, the biosphere can only interact with the sediments.