Lead was used for writing in Roman times. The 'lead' in a pencil is a mixture of graphite and clay. It is called lead because when the graphite deposit was first discovered in Borrowdale, England, the locals thought it was lead (or plumbago). Chemists later corrected them but the name has stuck.
Graphite is a form of carbon, like diamond, but softer.
Unlike lead, graphite is non-toxic.