The Prime Directive is the main principle that Starfleet/the Federation follows, barring them from interfering with the development of another less developed civilization. The question I am asking is where did this come from, out of universe? Did Gene Roddenberry or another Star Trek writer base this on an existing policy, or is this something original to Star Trek? If so, why did they come up with this idea, that seems totally unique to Star Trek?
I think I remember reading of policies similar to the Prime Directive in stories published before Star Trek was first broadcast in year one STE (Star Trek Era) or 1966.
As far as I can remember, I read a novelette by Chad Oliver dealing with an expedition to an alien planet with a mission to violate a similar rule in order to save the alien culture from a terrible disaster. Even though the aliens were saved, a lot of bad things happened during the mission.
As I remember, I read it in an anthology published a few years BST (Before Star Trek).
I think that the story was "Between the Thunder and the Sun" (1957), and I think that I read it in The Best From Fantasy and Science Fiction Seventh Series (1962).
E.E. Smith's novel The Vortex Blaster (1960) was set in the Lensman series, in the approximate generation after Second Stage Lensman (1941-42, 1953) and before Children of the Lens (1947-48, 1954). It was a mixture of original matter and previously published stories "The Vortex Blaster" (1941), "Storm Cloud on Dekka" (1942), and "The Vortex Blaster Makes War" (1942).
At one point the Vortex Blaster and the crew of his ship The Vortex Blaster visit the home planet of a crew member and defeat gangsters and/or tyrants. A Lensman questions whether they have violated the laws against revealing higher technology to less advanced worlds and as I remember Neal "Storm" Cloud replies that they demonstrated the use of their blaster weapons but didn't break the law because they didn't tell anyone how to make them and the natives already knew that blasters existed.
Since as far as I remember the world in question was the home world of a member of the The Vortex Blaster's crew it should have been advanced enough to build inertia less space ships or legally open for interstellar contact, and possibly even a member planet of the Lensman's government (which humbly called itself "Civilization"). Thus the Lensman version of the Prime Directive may have been even more strict in some respects than that of Starfleet.
Someone with access to The Vortex Blaster (1960) should be able to check my memory. I don't know if the law against revealing advanced technology originated in 1960 or in 1942.
Thus I was able to remember two examples of rules similar to the Prime Directive of Starfleet dating from 1957 and from 1960 and/or 1942.
And I have a feeling that I might later remember a better example of such a rule predating Star Trek once I post this answer and think: "Why didn't I remember this!".