Graphite and pyrite often occur together. When they are together in a rock, they suggest that the rock was originally sediment that contained lots of organic matter.
Here is a sample of a schist that is composed of graphite (black) with layers of pyrite (greenish yellow) crystals. But where is the organic matter? It is all gone because of intense heat and pressure that followed when the rock got buried deeper and deeper. The organic matter can not, of course, simply vanish (well, it can if it transforms into oil and gas and escapes the rock). It has to transform into something else. This something is mineral graphite which is composed of pure carbon.
Graphite schist with pyrite from Austria. Width of sample 12 cm.
But what about pyrite? Why is it there and how does it suggest that the rock originally contained organic matter? Pyrite is composed of iron and sulfur. Most commonly we find iron in combination with oxygen (minerals magnetite and hematite are very common). However, if there is not enough oxygen present, then we have a chemical environment that favors the formation of pyrite instead. What happened to the oxygen? It was probably the organic matter that consumed it when it decomposed. This is why I said that pyrite also suggests that perhaps this rock once contained organic molecules. There had to be lots of organic matter because some of it did not just decompose, it changed into kerogene (a precursor of crude oil) which later transformed into pure carbon. Graphite and pyrite occur together because they both need reducing environment to form1.
References
1. Deer, W. A., Howie, R. A. & Zussman, J. (1996). An Introduction to the Rock-Forming Minerals, 2nd Edition. Prentice Hall.