George Lucas was inspired by earlier science fiction films, particularly the Flash Gordon series from which he got the inspiration for the opening crawl used in every Star Wars movie except Rogue One.

Star Wars belongs to a sub genre of science fiction known as Space Opera, which featured:

"space warfare, melodramatic adventure, interplanetary battles, as well as chivalric romance and often risk-taking."...

"Hartwell and Cramer define space opera as "colorful, dramatic, large-scale science fiction adventure, competently and sometimes beautifully written, usually focused on a sympathetic, heroic central character and plot action, and usually set in the relatively distant future, and in space or on other worlds, characteristically optimistic in tone. It often deals with war, piracy, military virtues, and very large-scale action, large stakes." (wikipedia.org - Space Opera)

Star Wars' timeline placed in a non-specific time and place, shares similarities with fairy tales ("Once upon a time") and myths: stories about gods and heroes occurring at an unknown time and place in the distant past.

More Info: en.wikipedia.org