Mary Sue is a term in use primarily in Fan Fic circles to describe a particular type of character. This much everyone can agree on. What that character type is, exactly, differs wildly from circle to circle, and often from person to person.
The name comes from the 1974 Star Trek fanfic "A Trekkie's Tale". Originally written as a parody of the standard Self Insert Fic of the time (as opposed to any particular traits), the name was quickly adopted by the Star Trek fanfiction community. Its original meaning mostly held that it was an Always Female Author Avatar, regardless of character role or perceived quality. Often, said characters would get in a relationship with either Kirk or Spock, turn out to have a familial bond with a crew member, be a Half Human Hybrid masquerading as a human, and/or die in a graceful, beautiful way to reinforce that the character was Too Good For This Sinful Earth. Even back then, there wasn't a total consensus on what was or wasn't Mary Sue, since it's not always immediately obvious which character is an Author Avatar.