desert (v.)
"to leave one's duty," late 14c., from Old French deserter (12c.) "leave," literally "undo or sever connection," from Late Latin desertare, frequentative of Latin deserere "to abandon, to leave, forsake, give up, leave in the lurch," from de- "undo" (see de-) + serere "join together, put in a row" (see series). Military sense is first recorded 1640s. Related: Deserted; deserting.
desert (n.1)
"wasteland," early 13c., from Old French desert (12c.) "desert, wilderness, wasteland; destruction, ruin," from Late Latin desertum (source of Italian diserto, Old Provençal dezert, Spanish desierto), literally "thing abandoned" (used in Vulgate to translate "wilderness"), noun use of neuter past participle of Latin deserere "forsake" (see desert (v.)).

Sense of "waterless, treeless region" was in Middle English and gradually became the main meaning. Commonly spelled desart in 18c., which is not etymological but at least avoids confusion with the other two senses of the word. Classical Latin indicated this idea with deserta, plural of desertus.
desert (n.2)
"suitable reward or punishment" (now usually plural and with just), c.1300, from Old French deserte, noun use of past participle of deservir "be worthy to have," ultimately from Latin deservire "serve well" (see deserve).