If you get your just deserts, you get what you deserve.
The word ‘deserts’, in the sense of ‘what you deserve’, has been used in English since the thirteenth century.
‘Just’, of course, means ‘fair’.
It should be noted that the pronunciation of deserts in this expression is stressed on the second syllable, as in ‘desserts’.
The spelling, however, is correct.
A desert is an arid and desolate region of land, and its use as ‘that which is deserved’ is now limited to this single phrase.
It might help to think of it as ‘what you justly deserve’!
Example: "He stole millions of dollars from his company and today he was sent to prison for 20 years. He really got his just deserts."