Forty-seven has been the favorite number of Pomona College, California, USA, since 1964. A mathematical proof, written in 1964 by Professor Donald Bentley, supposedly demonstrates that all numbers are equal to 47. However, Bentley offered it as a "joke proof" to further a popular student research project that listed real and imaginative "47 sightings". Bentley used the invalid proof to introduce his students to the concept of mathematical proofs.
Joe Menosky graduated from Pomona College in 1979 and went on to become one of the story writers of Star Trek: The Next Generation. Menosky "infected" other Star Trek writers with an enthusiasm for the number 47.
The joke transcends Trek, also showing up in J.J. Abrams shows from Alias
(so it's an interesting convergence that he ended up doing Trek).