The lesson I recall being taught in school to distinguish the spelling of the word for an arid geographical area ("desert") and a sweet final course of dinner ("dessert"), is that "dessert has more s's because you want more of them. So why then, do economists and law professors when talking about people who get the reward that is due to them for their actions talk about a just "desert"?
Snopes.com, supported by the Oxford English Dictionary, confirms that the "desert" spelling in the phrase "just deserts", which is pronounced almost identically to "desserts" is correct, and takes the position that this is simply a case of a third word, spelled exactly like one and pronounced like the other, with a meaning all its own, rather than a meaning sense of either of the other words. As used in the phrase "just deserts", the word came into Middle English from the Old French desert "deservir" meaning to "serve well."
The sense of an arid place also enters the English language from Middle English via Anglo-French, but the root here is the late Latin word "dēsertum" (neuter), which is the noun use of past participle of Latin dēserere to abandon, forsake, equivalent to dē- de- + serere to join together (in a line).
None of these three words, apparently, correspond to the word "desert" in the sense of one who as engaged in the act that will give rise to his "desertion" from the field of battle and subsequent dishonorable discharge from the Army. The meaning of that set of letters comes to the English language not from Old French but from Middle French, a couple of centuries later where it is derived from the word "déserter" which in turn derived from the late Latin word "dēsertāre", which is a frequentative of the Latin word "dēserere."
Thus, both "desert" meaning arid place, and "desert" meaning to abandon have the same ultimate Latin source, originally closer in meaning to the sense of the word as abandoning a group, that developed a secondary meaning of a place that had been abandoned by water. Both words entered French and from there, English, with the original meaning of the Latin root entering English via French a couple of centuries after the secondary sense of the Latin word entered English from French.
The word "dessert" is the last of the words in this cluster to enter the English language, around the 17th century the word "dessert" meaning "last course," or literally "removal of what has been served," enters English from the Middle French "desservir" meaning "clear the table," literally "un-serve," from des- "remove, undo" (see dis-) and the Old French "servir" meaning "to serve".
The root in the "just deserts" sense and "dessert" sense, the French "servir" meaning "to serve" is the same, but in "just deserts" it comes from a word combination with a single "s" meaning to "serve well" while in "desserts" it comes from a word combination with a double "s" meaning to "unserve."
The two deep Latin roots become conflated upon making their way into English because the both "serter" and "servir" in French, end up producing "sert" in the mouths of Anglophones who drop the "er"/"ir" affix from conjugated French to unconjugated English, and had trouble at the time distinguishing the sound of "sert" and "serv" and hence failed to reflect the differences in their written language.