Carter's administration should have seen the tide turning against the Shah long before they allowed him into the country for medical reasons. With Iran's population already anti-American and growing in opposition of the Shah, when the President hosted the Shah in '77, it just fueled the hatred. Carter knew the Shah was on thin ice and still went ahead with toasting him at a dinner.
That worsened the situation, essentially sealed the Shah's fate. When he asked for entrance into the country after it became known he was dying of cancer, Carter initially opposed the idea, but relented because of humanitarian reasons. I believe Carter took a vote and they all told him to allow him in, even though no one knew what to do if they held Americans hostage.
Carter should have shut down the embassy and told employees there to evacuate when the Shah was overthrown. The situation was far too volatile and allowing the Shah inside U.S. borders only exasperated it. Had the embassy been shut down, none of this matters and Carter can bring in the Shah on humanity grounds.
Would avoiding the crisis be enough for Carter to win reelection? No. His approval ratings prior to the crisis were awful. In fact, the crisis boosted his approval ratings for a period of time between November & March, but after the botched operation, they quickly deteriorated and Carter quickly became a sitting duck. In fact, the only reason he held any lead against Reagan, really, was because his approval in early '80 was pretty respectable (he had a 52-38 approval in February of that year). But it slowly returned to pre-hostage levels and it ultimately led to his defeat.
So, had the hostage situation not happened, Carter's approval probably stays in the 20s & 30s, which is where they were at in October & November of '79, and he loses in a landslide - maybe even loses the nomination to Kennedy, since he wouldn't have had a boost of support at the crucial point of the '80 primaries.
However, had Operation Eagle Claw somehow defied the odds and was proven successful, I think there is a chance he's able to ride the high approval to reelection. Remember, in reality, Carter's ratings didn't tank until
after the operation failed. Had it been a success, it's possible Carter's ratings spike into the 60s and remain there through early spring & part of summer. Maybe the administration rolls out the hostages in the summer of '80 as heroes, throwing a massive parade in New York, giving him another boost in the ratings, or at least sustaining that boost.
I don't know if it would've been enough, but I think the goodwill would have certainly carried over into the late summer. From there, it all depends on how dramatic the ratings drop. If his approval entering the convention is 50-plus, he might go on to beat Reagan, though by a narrow margin.
More likely, he still doesn't beat Reagan, but has a far more respectable defeat:
Ronald Reagan/George H.W. Bush: 344 EV
Jimmy Carter/Walter Mondale: 194 EV
If his approval can stay above 50%, it might be enough to flip Michigan, Pennsylvania, Missouri and Illinois - which would deliver Carter the election with 280 electoral votes:
But I'd say scenario number one is probably the most likely. Carter was in a tough spot in 1980. Malaise was an issue and while a successful operation to save the hostages would have certainly boosted morale, I don't know if it would have held long enough to deliver him the election.