How do fossils help us determine the age of rock layers?
See answer below.
Let's say we have a bunch of rock layers and we can't date them (see image below).
Because of the Law of Supposition, we know layer A is younger than layer B and we know B is younger than C, but we don't know if layer B was deposited 1.5 million years ago (mya) or 3.2 mya. We have no way of knowing this.
Now let's say we identify fossils in some of these layers and we know roughly when the living organisms that made these fossils existed in the past. Let's pretend for the sake of simplicity that all the fossils we've found are really well-studied and our dating of them is as accurate as it possibly can be.
Now, we know that layer D cannot be any older than 4.5 mya because the fossil found there didn't exist earlier in time.
We know layer C was deposited no earlier than 3.0 mya but it couldn't have been deposited less than 2.5 mya because that fossil had went extinct and isn't seen 2.4 mya. It had already died out.
The more fossils we have, the better. In layer B, the fossil closest to the top doesn't tell us a whole lot on its own. If that fossil was the only fossil we found in any of the layers, all we could say is that layer B was deposited between 4.5-1.0 mya and that layer A is younger and layers C-F are older.
However, because we have two fossils, we can narrow our time considerably. If we see when those two fossils overlapped, when those two species existed on earth at the same time, we can conclude that layer B is between 1.0 mya and 1.6 mya. Any older than 1.6 mya and the lower fossil didn't exist. Any more recent that 1.0 mya and the fossil closer to the top didn't exist.
This method relies on our own knowledge of the fossils. Fossils are rare and sometimes we revise our dates if a fossil previously known to exist only from 1.5-2.0 mya shows up 5.0 mya. So, the more we know about the fossil, the more accurate our methods.