Tim Bowen sheds some light on the origins and definition of the phrase to pull someone's leg.

If you try to pull someone’s leg, you try and make them believe something that isn’t true. “You’re pulling my leg!” is another way of saying “I don’t believe what you’re saying” or “You must be joking!”.

It often has humorous associations but the origin of the expression has nothing to do with making jokes or telling funny stories. It has its origins in the criminal world of 18th and 19th century London. In those days street robbers often worked in gangs of two. One would trip up the unsuspecting victim and the other would remove his money and other valuables while he was lying on the ground. The robber didn’t literally pull the victim’s leg but caused him to stumble and fall and then lose his valuables. If your leg is pulled now, you don’t lose your money but you might betray your ignorance and lose your temper.