...hinged on the fictional universe it created, and how it resonated with viewers.
One aspect of that was the so called "Prime Directive".
The United Federation of Planets' (extrasolar UN equivalent) General Order #1 stated that:
As the right of each sentient species to live in accordance with its normal cultural evolution is considered sacred, no Starfleet personnel may interfere with the normal and healthy development of alien life and culture. Such interference includes introducing superior knowledge, strength, or technology to a world whose society is incapable of handling such advantages wisely.
Starfleet personnel may not violate this Prime Directive, even to save their lives and/or their ship, unless they are acting to right an earlier violation or an accidental contamination of said culture. This directive takes precedence over any and all other considerations, and carries with it the highest moral obligation.
The show originally aired when the United States began "Americanizing" the Vietnam War. The highest U.S. casualties occurred during it's run. (at least 45,000 dead)
The results of a particular political and military interference in a "less advanced" culture was being shown every night on the news during those years, and people were just beginning to see its disastrous effects.
After Star Trek's cancellation and as the killing in Southeast Asia continued, the Prime Directive began to seem like a damned smart way to conduct U.S. foreign policy.