A fox tries to eat grapes from a vine but cannot reach them; rather than admit defeat, he claims the grapes are sour and therefore undesirable. Thus goes one of Aesop’s many fables, and the term ‘sour grapes’ has its origin in this story.
Would you laugh at the poor fox for his attempt at rationalization, though? For instance, imagine an alternate universe where the fox had not chanced upon the unreachable grapes to begin with - the hero in that story would have been a happier and less frustrated individual (although just as hungry). A rational fox should attempt to maximize his happiness, and all else being equal, pretending to not need the ‘sour’ grapes is probably the closest he could get to this ideal.
So the next time someone throws the phrase ‘sour grapes’ at you, take it as a compliment.