The phrase is quite popular but I wish to know its origin. Is it possible that it has something to do with childbirth (also called kidding)?
Time for OED!
It seems to come from ‘make a kid of,' according to the Oxford English Dictionary.
So when I kid you, I am fooling you, and using your innocence (a childlike quality).
Or maybe I am treating you like a child.