Paleoecology is the study of how animals and their environments interacted in the distant past. While the basic idea has been around almost since we started the scientific investigation of fossils, it really only became a field in its own right around the 1950s. That's largely because it isn't easy, becoming harder the further back we go.
The basis of the field is to look, not at individual fossils, but at the whole array of fossils at some particular site, correlating them with what we can determine of the climate and environment at the time. Which, among other things, requires a good understanding of exactly what that time was and at least a reasonable confidence that the fossils in question are all around the same age. Often, it relies not just on good and plentiful fossils at a particular site, but on us being able to say what the animals' lifestyles were. Which is a lot harder for those that don't resemble the ones we have today - dinosaurs being an obvious case in point.