The right thing to do was say "Ok, you know who and what we are, so now we have a moral obligation to at least send some Starfleet personnel to guide you on all the modern science we have, and to help you develop the technologies on your planet". This way, they would have probably been ready to join the Federation in a few decades.
Holy crap, that's very, very far from the right thing to do! The whole reason there needs
to be a Prime Directive is that forcing that kind of rapid change on a culture is bound to be destructive. That kind of "We have a moral obligation to raise them to our level" mentality is what led the British Empire to inflict profound cultural subjugation and abuse on India, Africa, and other parts of the world, causing traumas that have resulted in ongoing turmoil and strife to this day.
The fundamental mistake is assuming that it's your decision. It's not. It's their life, their society. The PD is about having the sense and humility to recognize that it's their choice what to do about it, that they're more qualified to make that choice than you are. If they want
more contact, if they're given the freedom to govern how the contact happens and how much they adopt from other cultures, then they can advance successfully and in a healthy way, as long as it's at the pace they choose. But deciding that just because you're more technically advanced, that entitles you to force other cultures to become what you think they should be? History shows that that mentality is a great evil and brings nothing but harm.
Outside of the Trek universe, it was clear the "Prime Directive" was simply there to save money, since the Federation never had to get involved in anything, the shows never had to spend the money to show something that onscreen they could avoid doing.
No, the PD was there because the show was made in the 1960s, when the harmful consequences of Western colonialism and imperialism were rearing their heads in many parts of the world, particularly Southeast Asia; and the makers of the show were intelligent and aware enough to recognize how destructive well-intentioned cultural imperialism could be and how a responsible society needed a check against it.