Luke wasn't as much of a Mary Sue as Rey is. As mentioned above, he got bailed out by his mates constantly in IV. Han, R2 D2 and Obi-Wan all saved his life numerous times in the space of 2 hours. Han even ensured he had an open goal when blowing up the death star, without which he'd have died.
Then he fecked up constantly in V. Firstly by going out in the snow like a chump after the base was closed, then by leaving the sheltered cave and running out into the snow after chopping off that things arm with a lightsaber. Just murder the thing and stay indoors ffs. Then he disappoints yoda for an hour before leaving his training against the advice of people who know better to walk into a trap.
To those saying he held his own against Vader, I disagree. He fought Vader, but not really. Vader was toying with him, and could have ended the thing in 5 seconds if he wanted to kill him, but he didn't. He wanted to test him out, see how powerful he was and try and turn him. Luke was never even in danger. In fact as soon as he landed a lucky hit on Vader's shoulder, he cut his hand off about a second later. The fight was about him and the emperor checking out this "new enemy", nothing else.
Only in VI, where the purpose of the movie's opening act is literally designed to show us how far Luke had come, do we see significant development in Luke as a Jedi. He swoops in, saves his friends and murders the bad guys and looks confident doing so. Then at the end of the film he makes decisions based on things we've actually seen him learn from Yoda. He resists temptation and follows the advice given to him in V to save the day.
The final movie ties the three together nicely, and everything we'd seen Luke learn in IV and V actually affects the story. In TFA, Rey didn't even have a mentor yet and she was pulling off all sorts of shit. Mind control, flying ships and not only duelling with but actually beating a bad guy who while nowhere near as skilled as Vader, did actually want to harm her. Ren gave it his all, and Rey kicked his ass. That's where I think a lot of the Mary Sue comments come from, and the fact it took Rey one movie to do what took Luke 3.