The prime directive stems from ethics in anthropology, but taken to an extreme in some cases. In a basic sense, any conflict of interest between the person studying a people and the people themselves should favor the interest of the people. Though anthropologists usually find it deeply immoral to study a people in private, like we've seen with the duck-blinds in Insurrection and "Who Watches the Watchers".
In any case, the basis of morality, according to Kant, lies in not treating people as a means to an end, but rather as an end in an of themselves. In that sense, any interference in a people for personal gain is also deeply immoral. This, in essence, should be the groundwork of the prime directive: When studying or encountering a civilization, the party studying the civilization must not interfere in an effort to help with research, or to impose our morals on their civilization (such as interfering in a war, or meddling in policies in an attempt to better a civilization). What comes to mind with this kind of interference is the kind we usually think of as destructive—conquistadors and invaders who impose their own social structure onto other civilizations.
However, what Star Trek then does is take this to an extreme, saying that NO interference of ANY kind is permitted at ANY time, even at the cost of loss of life. However, saving a people from a natural disaster or preventing a star from exploding is not treating the people as a means, exploiting them. Indeed, saving a people helps them continue to be an end in and of themselves. And sometimes Star Trek DOES acknowledge this, as in "Pen Pals", when a distress call would seem to override the prime directive.
If a civilization asks for helps, then, it would seem that interference is permissible, if not morally required. What Star Trek fails to realize is that there can be inferred requests for assistance, inferred distress. In the United States, the police cannot enter your home without your permission or a warrant. However, if they see you being attacked in your home, for the same reasons as above, they are allowed to enter, as it can be inferred that if you could, you would request assistance.
Star Trek doesn't do this, though. The show, especially in Voyager, fails to apply reason to individual circumstances, analyzing the situation to see if it can be inferred that the civilization wants help. Instead, we get the usual argument of "The Prime Directive is correct because it is good. We cannot interfere." It is pseudo-philosophy at its finest.
Sometimes we hear the prime directive applied to post-warp civilizations, and this should most certainly not be the case. If warp travel is the border for which the Federation has decided to reveal themselves to civilizations, then surely if a post-warp civilization is in trouble, contact can be established and we can ask the civilization itself whether it wants help or not. In the case of the Klingon Civil War, it seems the Federation fails to recognize an official Klingon government, which would be the reason for non-interference. If they had, however, and the Klingon government had requested help, I doubt the Federation would have stood idly by while the Klingon people tore themselves apart in a Klingon civil war. Just like modern countries can request peacekeeping operations from other countries.
The Prime Directive is correct and moral in principal, but it has been taken too far to an extreme. If a planet is destroyed, or a ship is about to explode, we can surely assume that any rational being in that situation would want to be saved, and therefore we are morally obliged to help.