It may seem confusing, but the word "dessert" originally came from the French word "desservir," meaning "to clear the table" or "to un-serve." Since dessert was typically served after the main course was cleared away, it became associated with the act of "desserving."
Over time, the word evolved into "dessert" and the meaning shifted to refer to the sweet course itself, not the act of clearing the table.