George Lucas was initially inspired by the comic book Flash Gordon, and wanted to adapt the story into a film. When he couldn't procure the rights, however, he had to create his own science-fiction universe, and the result was Star Wars. Lucas began by writing for eight hours a day starting in 1971, trying to craft original characters and an entire universe in which to set his "space opera."
While science fiction movies were being made at the time, Lucas was determined to make a different kind of film, one that was more optimistic, less dark, and aimed at younger audiences. He is quoted as saying in an interview at the time, "The reason I'm making Star Wars is that I want to give young people some sort of faraway exotic environment for their imaginations to run around in...I have a strong feeling about interesting kids in space exploration. I want them to want it. I want them to get beyond the basic stupidities of the moment and think about colonizing Venus and Mars. And the only way it's going to happen is to have some dumb kid fantasize about it—to get his ray gun, jump in his ship and run off with this wookie into outer space. It's our only hope in a way."
Lucas took inspiration from many different sources for crafting the world of his film. The metallic body of C-3PO was inspired as much by the Tin Man from The Wizard of Oz as it was by the robot Maria from the 1927 German expressionist film Metropolis. Darth Vader's mask was inspired by oxygen helmet worn in the 1935 film The Phantom Empire and by Nazi headgear and WWII gas masks. For the plot itself, Lucas sought inspiration from Celtic folklore, Taoism, the history of Nazi Germany, the Vietnam War, and spaghetti Westerns.