I googled till I felt I was losing my own marbles, and all I could find indicated that the expression came from the game of playing marbles. To lose one's marbles was a terrible thing. There was one site that traced the game of playing games of marbles to the Ice Age (when was that exactly?)...