Lost My Marbles Peter Pan

Can you tell me the origin of the expression he has lost his marbles meaning gone mad or lost his reason or done something really stupid.
Lost my marbles peter pan.
Source : pinterest.com
Lost my marbles peter pan.