In elementary schools in the United States, they introduced first graders and such to the concept of grades by using simple ones, like:
"S" = Satisfactory
"N" = Needs Work (not good, but not complete screw up)
"U" = Unsatisfactory (complete screw up)
As they transitioned kids towards real grades in like 3rd grade (A thru F), they decided it was too harsh to dump a kid from a D straight to an F. So, someone came up with the idea of "E" for "Effort".
Hence, the phrase "you get an 'E' for Effort" came about.
So, "E for Effort" was a grade of something. And "E" in math meant you needed some serious help (like tutoring) to pass math, because you were on the verge of failing.
But, over time, folks that used this phrase started to change it to make Effort seem like the thing being graded, not the grade itself.
So, you got stuff like "You get an A for Effort."
In this case, Effort would be the fake subject the person was being graded in. (This was never any part of school, though. Kids didn't suddenly have an "Effort" category on their report cards with an A thru F. Acting like Effort was a subject to grade was confined to folks modifying the phrase over time).
So, this changed the phrasing from
"E for Effort" = "You tried something, but failed. I acknowledge that you tried, but you need to work harder if you want to succeed."
... to ...
"(grade) for Effort" = "You tried, and and failed. But, here's how well (or poorly) I think you tried." (A for effort = I think you tried well, even if you failed. F for effort = you tried and really suck at this.)
The "A for Effort" may seem more sincere, but it depends on how someone says it (IE: if they say it sincerely or sarcastically). Often depends on the circumstances, too.
EG1: if a person was stuck in a no-win situation, but tried their hardest to deal with it, another person saying "you get an A for Effort" is letting them know they were in a situation where they didn't have a "best option" only a "least crappiest", and the person did the best they could given the circumstances.
EG2: if a person royally borks something up, often something that should have been easy, or was assumed that the person knew how to do, another person may say "you get an A for effort" as a sarcastically snarky response to rub their nose into how incompetent they are. "Mike royally screwed up the driving test by crashing the car. Well, he gets an A for effort. I'm impressed." (A person using it sarcastically is often expecting someone to fail, and uses the phrase as a way to underline how much of a screw up they expect that person to be, and how the results the person created just prove how much of a screw up the person is.. so it's really a complete a-hole thing to say at that point.)
EG3: Someone could use the term in complete surprise or awe or to signify being impressed, but usually at how massively someone screwed up. Like some parents show up from vacation, and their kid has thrown a party w/o permission. But, the car is in the pool, the house is in shambles, etc, etc. The place is a complete disaster. And, one of the parents is just impressed with how insane the party must have been so they go "Well, he gets an A for effort for that party."