We deserve things based on our actions. For example, many people believe murderers deserve the death penalty.
Deserve is used in many ways, but it always carries a sense of balance or justice. If someone receives an award for their work, it means they deserve praise and attention. If you deserve a day off, it means you've been working hard and have earned a vacation. If you threw a book during class, you deserve a punishment of some kind. Many laws — and lots of arguments — are about deciding what different people deserve. It's often hard to tell.