|You know it makes sense|
The Prime Directive appears in the original series, and by some accounts originated in a critique of the Vietnam War. It also proved to be a very useful plot device.
In the original series, it is handily summarized by Kirk and Bones as "No identification of self or mission. No interference with the social development of said planet... No references to space, or the fact that there are other worlds, or more advanced civilizations." ("Bread and Circuses", TOS.) This is generally followed, though Captain Kirk tends to a flexible interpretation. But it does not seem to completely prohibit assistance. In "Friday's Child", for example, the Federation had apparently offered to set up hospitals, but found the inhabitants uninterested. It certainly does not mean leaving the inhabitants to their fate in all circumstances: in "The Paradise Syndrome" the Enterprise has to save a planet from an asteroid—but the inhabitants mustn't know. This makes sense; saving them allows their society to go on developing, whereas "non-intervention" would render the whole question moot. As a guideline, this principle of non-interference seems sensible.
The issues are discussed in "The Apple" (TOS, 2nd season). The Enterprise comes to a paradisial planet where the inhabitants, apparently immortal, lead a simple life in service of Vaal, the machine that apparently maintains this stasis. Vaal has forbidden sex but they are too innocent to mind. McCoy argues that this is contrary to the right of people, human or not, to develop, while Spock argues that to intervene would be a violation of the "non-interference directive". He tells Bones that "you insist on applying human standards to non-human cultures. I remind you that humans are only a tiny minority in this galaxy .... these people are healthy and they are happy. Whatever you choose to call it, this system works, despite your emotional reaction to it." Kirk however decides on the basis that Vaal is threatening the ship and the only way to survive is to destroy it. It is clear that Kirk believes it is in the people's interests to be freed from Vaal, but his decision doesn't seem to be based on that. For Kirk it is always about the ship.
In TNG, however, not only has the rule become more formalized but the Federation seems to have adopted a sort of fanatical fundamentalism about the Prime Directive. This is believable; societies cannot believe in nothing, and if Earth has abandoned religion (as sometimes seems to be implied) it is plausible that it has adopted a sort of unreasoning devotion to founding documents. In more than one episode of TNG, the idea appears that the Prime Directive requires the abandonment of a society to natural destruction even when it can be saved without affecting its social development. Statements are made that whenever humanity has intervened in the affairs of a less developed culture, however benevolently, the results are always disastrous. But when the alternative is certain to be the total annihilation of the less developed culture, this argument makes no sense at all. (Getting back to Vietnam, remember the claim that "we had to destroy the village in order to save it".) In "Homeward" (TNG), there is an attempt to answer the case by an exchange in which one character says that the Prime Directive was intended to safeguard development and Troi says that actually it was "to ensure non-interference". Apart from being tautological, this is not in accordance with TOS.
It is noticeable that whereas in "The Apple" (TOS) McCoy and Spock are essentially arguing about what is the right thing to do. McCoy believes that a society should change and develop; that people (thinking beings) have a right to free development that their society should not prevent. Spock asks who are they to decide what should happen in a different society, and points out that it works. However, later the arguments are about the Prime Directive, which is a given although one may be unsure how to apply it.
The Prime Directive is a good plot device, but as a plot device it usually functions as the problem rather than the solution. It is supposed to be the great rule, yet it requires something unreasonable. So they have to find a way round it or steel themselves to break it. This sometimes makes for good stories but it becomes increasingly problematic that they don't start to question the Prime Directive itself (or rather its extreme version).
One notable case is "Pen Pals" (TNG). Data eventually persuades Captain Picard to save a planet, which can be done without cultural interference, but initially Picard was going to veto this. There is an interesting, though rather odd, discussion among the senior staff. (In some ways the debate in "The Apple" is a clearer presentation of the issues, perhaps because in TNG no-one is ready to question the Prime Directive in the way McCoy does.) Picard suggests that though the interventionists see a clear case when it's a geological disaster, or an epidemic, it becomes less clear when it is a war. Or what about just oppression? The Prime Directive saves us, he says, from allowing our emotions to overcome our judgment.
This is interesting, but logically fallacious, an example of the bad sort of "slippery slope" argument. In any case there is a quite clear dividing line at the point of natural events which will destroy a whole people. Although Dr Pulaski said in this discussion that she would intervene in an epidemic, you can certainly argue that (unless the epidemic is going to kill everyone) responding to epidemics is part of cultural development. On the other hand, we know from "Assignment: Earth" (TOS) that Earth itself only survived the nuclear arms race because of the intervention of the unnamed superior civilization which sent Gary Seven and Isis, so perhaps the Federation should have a bit of a think about all this. For that matter, in "Errand of Mercy" (TOS) the highly advanced Organians intervened to stop a Federation-Klingon war, and that apparently worked out fine.
As to emotions and judgment, what Picard actually means is that a rigid rule saves you from having to exercise judgment. And Picard eventually comes round because of his emotional response, while Data's compassionate response was not based on emotion. (See my comments on "Pen Pals" in Data's Humanity.) Curiously, in a slightly different context ("Justice", not an episode I re-watch often) Picard says that there can be no justice if laws are absolute.
In "Homeward", Captain Picard is manoeuvred into saving a small group from a doomed planet by Worf's brother, who presents him with a fait accompli by beaming the group aboard (into a holodeck simulation). As usually seems to happen in these cases, at the end the participants seem to realize that they did the right thing.
Some attempts to justify the Prime Directive in stories don't come out very well. In "Patterns of Force" (TOS), a historian has introduced a sort of Nazism to another planet, with the idea that its supposed efficiency could be turned to good ends. But this doesn't actually work out very well (you amaze me, Holmes). At the end he laments, "The non-interference directive is the only way!" If you say so, professor. But it seems a bit of a stretch to say that because introducing Nazism was a bad idea, no-one should do anything.
Another one, which is rather better, is "Friendship One" (VOY). It is revealed that Earth sent out an unmanned probe soon after the invention of warp drive, carrying technical information to assist others. Voyager finds that it led to a society adopting a technology which they could not control and which devastated their planet. The probe was sent before Earth had any of the later ideas of non-interference. It is quite plausible that sudden acquisition of advanced technical knowledge, without the scientific background that led to it, could lead to disastrous mistakes. As a justification for the Prime Directive this isn't conclusive—one could argue that the problem is precisely the isolation of the information from any contact with the more advanced civilization which could advise on it—but it's certainly a reasonable example in favour.
In "Dear Doctor" (ENT) Captain Archer decides not to help a society dying of a plague, because it would be interference, but the issue is not quite pure non-intervention, since the planet has already been in contact with other interstellar civilizations (including the Ferengi) and the Enterprise communicates openly with them. This episode is particularly unsatisfactory and I have treated it separately.
The Prime Directive may be seen as allegory about the present day, especially about the United States. However, one weakness with this is that tends to make issues of judgment into absolutes, and obscure specific reasons. For example, the invasion of Iraq. This involved both a violation of the international order by launching a war of aggression and lying about the reasons. To represent this by the issue of intervening benevolently would be seriously misleading.
Symbolically, the Prime Directive can also be seen as about an anti-imperialist argument. Technically advanced western powers' interventions in other societies had negative impacts. However, the Prime Directive (as a symbol) seems a bit off-kilter. It seems to imply that the problem with colonial encounters was simply about the mismatch of level of development. It's true that some damage was accidental, as for example with the introduction of diseases. But in fact these encounters were typically violent and predatory in nature.
The Prime Directive is also sometimes connected to the Federation's policy of not interfering in the internal affairs of other (advanced) political entities. This is in my view a different issue. Some fan debates about the Prime Directive bring up the atrocities of the Third Reich. This is not completely irrelevant, but many of those who write seem not to understand that the Second World War in Europe was not fought in order to stop these crimes (although it did so), but because of Nazi Germany's international aggression.
No discussion of the Prime Directive can be complete without mentioning "A Piece of the Action" (TOS). The planet's society derived from a visit from an early Earth ship before the adoption of a non-interference rule. The influence was apparently accidental, the leaving behind of a book about 1920s Chicago gangs, which was taken as a sort of scripture about how to model their society... This is the episode in which Captain Kirk invents the card game "Fizzbin". The rules are very simple, as long as you remember whether it's Tuesday and keep an eye on whether it has got dark.
Of course, Star Trek is fiction. If nothing else, the Prime Directive gets people thinking.