Pencil "lead" contains graphite (a form of carbon) and clay. The amount of clay in the mixture when making the pencils determines how hard the pencil "lead" is. Since graphite and clay are both cheap and the desired hardness is easily predictable based on the ratio of graphite to clay when mixing graphite is ideal for pencils.
In manufacturing many things are considered. Easy to use, cheap to produce and availability. Graphite ticks all these boxes. It is non-toxic and in much abundant also very fast to produce