There is great mileage to be had from the literary convention of making things seem grimmest just before the final victory.
The PCs will prevail in the end. You know they will. They're the heroes, after all. They will win. Well, unless you're going for a deliberate total party kill, or they make some ridiculously bad decision and end up dying in some trap that they should easily have evaded.
Okay, so the PCs will prevail maybe 30% of the time. The point is that to make their final victory seem even sweeter, you pile on the impossibility of them winning through. Make the situation seem utterly hopeless. Send it from bad to worse, to downright despair. When they look utterly overwhelmed by the first 50 orcs, throw another 50 orcs at them. And then another. And a dragon.
Because when the PCs finally achieve their hard-earned victory, it will feel so much sweeter.
Transcript
Darth Vader: I shoot. 7
GM: Wedge dodges... <roll>...
[SFX]: Pow!
GM: The shot clips his manoeuvring controls.
[SFX]: Boom!
Wedge: I'm hit! I can't stay with you, good buddy!
Luke: Oh thank god!
Luke: That... you're all right. You'd... better go back to base.
Luke: Princess, Wedge is returning to base. Not me, Wedge. Who is a shapeshifter.
Leia: What's your point? No, don't answer that. Just shut up and fly.
Luke: Biggs! Bogeys at 6 o'clock! Whatever you're doing to dodge, do it more!
Biggs: <glug glug> Dayamn! Fresh out o' moonshine! <roll>
[SFX]: Pow!
[SFX]: Kaboom!
GM: Everyone in the attack fleet is dead, except Wedge, who's limping back to base, and you.
R2-D2: Huh. If only I'd had another second for my vector calculations, I could have saved everyone.
[SFX]: < be-zioo dip-deep jang bleep boop doodle >
Luke: If?! And if this was a video game I'd be reloading our last checkpoint so fast it'd make your head spin!