It obviously dates from a time or a culture in which cooking vessels were suspended over a fire. I remember when I first heard it - it seemed very odd to me, as in my experience neither pots nor kettles were black.
I've always assumed it was based on the idea that both pot and kettle were regularly placed over an open fire and would therefore both be black. So for one to accuse the other was hypocritical.
But this, from Brewer's Dictionary of Phrase and Fable, 1870 (revised), tells a different story.
"The pot calling the kettle black: Said of someone accusing another of faults similar to those committed by the accuser. The allusion is to the old household in which the copper kettle would be kept polished, while the iron pot would remain black. The kettle's bright side would reflect the pot. The pot, seeing its reflection, would thus see black, which would appear to be on the side of the kettle. The pot could then accuse the kettle of a fault it did not have."
But I actually had a scenario in mind: a student who clearly did a sloppy job in an assignment blamed me for not laying down the instructions clearly. As his fault isn't the same one he accused me with, I'm not sure the pot and kettle idiom really applies...