Star Trek had its solution: no contact or interference with civilizations that didn't develop warp drive yet. The goal of the rule was to not contaminate the development of another civilization. In today's terms, you could generalize it to: no contact with a civilization until it's about to, or already did, figure out that there are others in the universe.
Which is kind of in between of the positions you described in the comment.
Beyond "it showed up on a popular television show", there is very little reason to believe in the Prime Directive being a real thing. It already appeals only to a particular subset of humanity, and there's little reason to believe it would appeal to all aliens. And there's a lot of humans who would consider it actively immoral, too.
It's one of those Fermi paradox answers that requires all of the supposedly millions or billions of intelligent species to all happen to have adopted one particular answer uniformly and for all time. Those answers aren't very compelling without a rock-hard explanation as for why it's absolutely mandatory that all star-faring civilizations will A: adopt that ideal immediately and B: keep that ideal intact for millions or billions of years despite all the changes they may go through.
The Prime Directive was a tool for creating drama, not a well-thought-out philosophical statement on the inevitably of certain ethics. Heck even in Star Trek itself, only the Federation has this policy, which it violates accidentally and otherwise fairly often anyhow. The other major civilizations show no sign of having this policy at all.
It is also an easy answer to try to explain the Prime Directive in a dramatic setting in such a way that our real world might still be in a space full of aliens, despite the fact that if space was really crawling with aliens there shouldn't be any such thing as virgin territory anymore and everywhere in the galaxy should be showing millions of years of proof of alien interactions, just as it's increasingly hard to find a square meter of Earth's surface that doesn't have some sort of unambiguous evidence of the presence of a technological civilization, if examined with powerful enough tools.
Which they violated whenever the script required it :-)
It's the 'figure out there are others' bit that made something like the Prime Directive problematic. Given our advances in sensing and observing technology we are much more likely to 'see' an advanced civilization before we can actually fly out to meet them. If you know that there is intelligent star faring people living on a 'nearby' star, and they happen to have been observing your progress, do they introduce themselves or wait for you to figure out how to reach them?
>Given our advances in sensing and observing technology we are much more likely to 'see' an advanced civilization before we can actually fly out to meet them.
I don't think this is really true (though I could be wrong, I am not an astronomer). Sure, we may be able to "see" evidence of an advanced civilization, but without warp drive, we won't have real proof. All we'll have is some observational data showing that, for instance, the light from their host star dims in a really weird way that's unlike anything we've seen before in our observations, or that there's some object sitting in their L1 spot, etc. We can hypothesize that this data indicates artificial structures, because what natural phenomenon could possibly cause such things? But that's not proof; there really could be some natural thing causing those readings.
So the ETs don't really have to establish contact until we have warp drive and the actual ability to go see these artificial structures up-close. They can just leave us to sit around our planet wondering what these observations mean, and slowly come to grips with the idea that there may very well be some intelligent ETs out there with starshades, and argue over it for a few centuries as we'd surely do. They have no obligation to come visit us and clear up the matter. And considering how backwards, irrational, and violent a species we are, there's no good argument I see for the ETs to rush first contact with us, and every reason to delay it as long as possible.
We'll be able to see the spectra from distant planets soon. That will amount to "seeing" advanced civs.
Going to them with warp drive without landing and talking to them would be equivalent. What would you be able to do? Basically sense EM radiation from there with better resolution, but it's essentially the same thing, "seeing".
You'll have to explain how seeing spectra from distant planets conclusively proves intelligent life. I don't see how it does. Spectra will tell you that a planet has molecular oxygen, for instance, carbon dioxide, etc., which would indicate an atmosphere like ours, which would indicate life similar to ours (doing photosynthesis), but you'd get that on a world occupied solely by plants, or with only non-intelligent life. Anyone looking at Earth before about 2M years ago (or anyone looking at it now, but more than 2M ly away) will see exactly this: a life-bearing planet with no life intelligent enough to build a civilization.
Finally, even if we could conclusively detect a civilization on a distant planet, that still doesn't explain why they have any obligation to contact us. They can easily just ignore us, and I for one can see why they would. The only time they'd really need to strongly consider establishing contact is when we have sufficient capability to visit them, and that's never going to happen the way we're going. It'd probably by prudent on their part to spy on us though, since we're a potential threat.
Kind of like Asimov's 'Three Laws', really. It's a talking point and a foil for the plot. It was never intended to be a realistic and workable solution.
On the other hand, (at least in the I, Robot stories) the Three Laws actually seem to be fine as a realistic/workable solution; all the conflict revolves around robots being programmed to not obey them, whether due to added rules before Rule 1, elided rules, or reordering of rules.
Prime-Directive-related conflicts, meanwhile, seem to revolve around cases where the Directive itself is flawed (or at the very least not ideal for a given situation).
The funny thing is that the popular culture somehow missed the memo, and often treat the Three Laws as if they were really wise. You can see this happening in every other article about AI these days.
The trouble is that we really have no way to make faster than light travel, and probably won't for hundreds or thousands of years, if ever. Meanwhile, our ability to see and detect our neighbors gets better and better every year.
It could be that we go 100,000 years without ever being able to reach other stars, but spend the entire time passing messages, like prisoners in individual jail cell passing notes to friends in nearby cells.
... Damn, that would be a really great setup for a sci-fi story...
Vernor Vinge's "A Deepness in the Sky" posits something like this; FTL travel is impossible, but it is possible to help civilizations bootstrap via an internet-like broadcast system that is inherently built to operate at the speed of light.
(Those who have read the novel(s) in question will probably find my description of the Qeng Ho network incomplete at best, but I don't want to write too many spoilers.)
I think the whole point of the "Prime Directive" was to provide absurd, immoral unintended consequences when it was slavishly followed with religious zeal. High drama then ensued when the Captain then had to choose to break the rules and risk his career to do what was obviously (to the viewer) right. Like a galactic example of zero tolerance rules in an elementary school. Sometimes the aliens chew their toast into the shape of pistols and shout bang, bang.
it's also a good scapegoat to people wondering why they only fight the monster of the week on the many preindustrial planets they meet then adbandonig them to their quotidiane misery afterwards instead of, you know, dropping a basic medicine handbook and a civil engineering primer so they don't all die from infection and water shortages.
The Prime Directive and Asimov's 3 Laws of Robotics aren't well-thought out, thoroughly researched concepts that are designed to be followed. They are reasonably sensible sounding ideas that have inherent weaknesses that give rise to interesting story elements. So much of Star Trek and so much of Asimov's stories revolve around the failings of the laws they purport to follow. They are stories, they are not meant to be guidelines for either AI or interstellar contact.
Which is kind of in between of the positions you described in the comment.