Breach of Contract
Breach of contract is a failure by one party to keep a promise in a binding agreement without a legal excuse. In a home sale, it can be a buyer refusing to close without a valid contingency, or a seller refusing to sell.
A buyer's breach is the usual way earnest money is lost. If a buyer with $10,000 in escrow on a $500,000 home misses closing after their contingencies have expired, the seller may claim the deposit under the contract's default terms.
A seller can breach too. When the seller fails to perform, buyers are usually entitled to their deposit back, and some contracts also let them seek specific performance or damages. When both sides claim the money, see earnest money disputes.