Originally the Prime Directive prohibited interference with pre-warp cultures. The rationale behind the Prime Directive was that, no matter how good your intentions may be nor how terrible the thing you’re trying to prevent might be (in terms of plague or Holocaust or natural disaster), interference from a technologically advanced civilization was always worse for the native culture and the native population than letting the bad thing happen.

The ethics of this are debatable, but its roots are in the historical reality of advanced cultures interacting with less advanced cultures here on Earth. (Spoiler: It always ends badly for the less advanced culture.) In-universe, you can easily postulate that the Federation has studied a lot of practical cases (including those where they tried limited interference) and eventually concluded that interference is just a bad idea.

Thematically, it should be noted, the purpose of the Prime Directive was almost always about giving the protagonists something to rebel against: The Prime Directive says we shouldn’t do this, but we’re going to ignore it and save the day. The Prime Directive was thus characterized as something that was generally a good idea, but not always specifically a good idea. (I also don’t believe that the original series ever invoked the Prime Directive in order to justify standing aside and allowing a genocide to occur.)

The use of the Prime Directive saw a major thematic shift following the episode “Symbiosis” in the first season of Star Trek: The Next Generation. In this episode, Captain Picard uses some very clever Prime Directive judo after he discovers that one pre-warp civilization is selling another pre-warp civilization addictive drugs as the “cure” for withdrawal from the addictive drug. He can’t interfere by warning the addicted civilization, but he eventually resolves the situation by refusing to repair the freighters they use to deliver the addictive drugs. (He sure is lucky that the civilizations have lost the tech to repair those freighters for themselves!)

This episode was a clever little inversion of the traditional Prime Directive story, but its success largely characterized the use of the Prime Directive going forward: It was the thing to be obeyed slavishly, usually with a convenient Hand of the Author to set up a convenient series of coincidences to “prove” the rightness of the Prime Directive.

The next major shift in the Prime Directive came with the “Pen Pals” episode in the second season of TNG. In this episode, Picard claims that an entire species of intelligent life should be allowed to die in a natural holocaust because it was the “natural development” for that society. At the end of the episode, the Prime Directive is quietly bent in order to save the alien race (one of the last instances in which this would happen), but the precedent of “the Prime Directive says we should let extinction-level events happen from external causes” had been set. (This, IMO, is the point where the Prime Directive transitions from a decent directive for starship captains wielding civilization-altering technology without any immediate oversight to a completely contemptible and horrible concept.)

The final metamorphosis of the Prime Directive came during Voyager when it began getting applied to species capable of warp travel. The Prime Directive had become evil, now it was destined to become totally idiotic as Janeway ping-ponged her way between epic space battles one week and claiming that the ship couldn’t defend itself because of the Prime Directive the next.

Voyager also had a terrible predilection for the most contrived Hand-of-the-Author Prime Directive stories. For example, in “Prototype” we have B’elanna disobey Janeway’s claim that they can’t help a species of warp-capable androids because of the Prime Directive. Then, at the end of the episode, it turns out the androids were coincidentally racist genociders. (It’s the storytelling equivalent of claiming that you should never help hitchhikers because it might turn out that they’re Hitler on their way to register for public office.)

As a final footnote, we have “Dear Doctor” from Enterprise. In this episode, featuring a Prime Directive crisis before the Prime Directive existed, the Hand-of-the-Author which had become a metastatic cancer in Voyager is revealed to be a literal Hand of God: The Valakians are literally meant to go extinct so that the Menk can inherit the planet. A doctrine which had become completely vile and nonsensical is now sanctimoniously defended as an article of essentially religious faith.