Why is it called earnest money?
Because "earnest" is an old word for a pledge, a part payment made up front to bind a deal. It is not the same word as "earnest" meaning sincere. Earnest money is a down payment on your promise to buy, which is why the name stuck in real estate.
Dictionaries trace the pledge sense back to Middle English "ernes," from Old French "erres," meaning earnest money. That came from Latin "arra" or "arrha," borrowed from the Greek "arrhabon," which most sources link to a Semitic word for a pledge, such as Hebrew "eravon." The final "t" probably crept in from the other "earnest," the one that means serious.
The two meanings fit together anyway. A buyer who puts real money at risk is showing good faith. Today the deposit is usually written into the purchase agreement along with the terms for getting it back.