I think it came about by Siddhartha considering life, how to avoid suffering... though there are probably different versions.
in one kind of Buddhism, I think there's the saying "if you meet the Buddha on the road, kill him"
another saying, "if they ask you what your teacher is, tell them 'a roll of toilet paper'"