Wikipedia
Paleofeces (UK: Palaeofaeces) are ancient human feces, often found as part of archaeological excavations or surveys. The term coprolite is often used interchangeably. Intact feces of ancient people may be found in caves in arid climates and in other locations with suitable preservation conditions. They are studied to determine the diet and health of the people who produced them through the analysis of seeds, small bones, and parasite eggs found inside. The feces can contain information about the person excreting the material as well as information about the material itself. They can also be chemically analyzed for more in-depth information on the individual who excreted them, using lipid analysis and ancient DNA analysis. The success rate of usable DNA extraction is relatively high in paleofeces, making it more reliable than skeletal DNA retrieval.
The reason this analysis is possible at all is due to the digestive system not being entirely efficient, in the sense that not everything that passes through the digestive system is destroyed. Not all of the surviving material is recognizable, but some of it is. This material is generally the best indicator archaeologists can use to determine ancient diets, as no other part of the archaeological record is as direct an indicator.
The process that preserves the feces in a way such that they can be analyzed later is called the Maillard reaction. This reaction creates a casing of sugar that preserves the feces from the elements. To extract and analyze the information contained within, researchers generally have to freeze the feces and grind it up into powder for analysis.