It was originally to force the cashier to open the till.
Say an item was $20. If the customer paid with a $20 note, then the cashier could, intheory, pocket it, without it showing up on the rocords. If it was $19.99 they needed to open the till to get a cent out. This meant it was recorded, and so the till wouldn't balance.