According to Don Knotts's autobiography, the idea of the film originated during the writing of The Ghost and Mr. Chicken (1966). Knotts and screenwriter James Fritzell were in a tall building writing the script, but Fritzell's partner, Everett Greenbaum wouldn't join them because of his fear of heights. Knotts and Fritzell then began joking about the worst job to have if one was scared of heights. Being an astronaut was the top choice.
The film was set for release shortly after the Apollo 1 fire which took the lives of 3 astronauts, which raised questions about the appropriateness of releasing a space themed comedy film so close to the tragedy.
While the film makes a big deal about the United States launching the first person into space with no military experience, the feat had already been done, in real life, by the Russians. Not only was she the first woman in space, but Valentina Tereshkova was the first person with no military experience, and only person until the 1980s.