It's a problem that's been played out with secret government programs, epidemics, terrorist threats, military plans, etc., etc. There is an obligation for the public to know about these things for their own good and to keep a check on government power.
As for Iran, the hostage takers wanted that publicity. That's why they took over such a highly visible target as the embassy. The coverage was important because it kept pressure on the US government to do something. Had we just forgotten about the hostages, they surely would have been killed.
Seven months is a long time- you have to wonder what his captors were expecting after all these months. They didn't receive a ransom and without publicity there was no political glory in it for them, so why did they sit on the story?