The idea that became the Hitchhiker's Guide happened whilst Douglas Adams was lying drunk in a field in Innsbruck. The BBC used to say this happened in Spain, but we know how to spell Innsbruck now.
In early 1977, a producer called Simon Brett decided that Douglas' talent needed an outlet other than the odd sketch for Weekending, and the pair of them came up with the idea of a comedy science fiction series.
Originally the show was to have been called The Ends of the Earth, and each show ended with the earth being destroyed in a new and interesting way. A pitch for Hitchhiker's was eventually submitted - and Arthur Dent's name was changed from Aleric B in the taxi on the way to the meeting.
There was some debate as to who should play the voice of the guide. Everyone wanted a 'Peter Jones-y sort of voice', and several people were auditioned. Eventually a secretary pointed out that perhaps Peter Jones might fit the bill.
A pilot show was comissioned, and would become the first episode of the series after Simon Brett had persuaded the upper echelons of BBC management that yes, it was funny. The show got the go-ahead on August 31st, 1977.