E. Cobham Brewer 18101897. Dictionary of Phrase and Fable. 1898.
Every bean has its black. Nemo sine vitiis nascitur, everyone has his faults. The bean has a black eye. (Ogni grano ha la sua semola.)
He has found the bean in the cake, he has got a prize in the lottery, has come to some unexpected good fortune. The allusion is to twelfth cakes in which a bean is buried. When the cake is cut up and distributed, he who gets the bean is the twelfth-night king.