Deserve, merit, earn, rate mean to be or become worthy of something as recompense whether by way of reward or punishment.
Deserve implies a just claim which entitles one to something good or evil, usually on the ground of actions done or qualities shown; it does not necessarily imply that the claim has been won or recognized.
Merit is so close a synonym of deserve that it is often used interchangeably with it without loss. Even so, slight differences in meaning may be detected. Merit, although it implies a just claim, seldom suggests that the claim has been urged by oneself or another, a connotation that is not essential to but may often be found in deserve; merit also more often implies qualities of character, of life, or of action that entitle one to reward or punishment.
Earn may suggest a due correspondence between the efforts exerted or the time or energy spent and the recompense that ensues; it fundamentally implies a deserving or meriting as well as a getting and therefore may suggest a return in evil as well as in good.
Rate implies recognition of deserts or merits usually upon a carefully calculated basis, but it does not carry any suggestion of whether what is deserved or merited has been given.