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."