A belated realization of something after a period of confusion or misunderstanding.
The Oxford English Dictionary states that this phrase originated by way of allusion to the mechanism of penny-in-the-slot machines. The OED's earliest citation of a use of the phrase, in Nigel Balchin's novel A Way through Wood, 1951:
"I sat and thought for a moment and then the penny dropped."
The image of someone waiting for a penny-in-the-slot mechanism (which often jammed) to operate does sound plausible and, if that isn't the origin, it is difficult to image what is.
The usage is surely earlier than 1951 though. Public toilets still then required users to 'spend a penny' in order to unlock the door to get in but, even counting those, coin operated machines were much less common than they were in Victorian times.