It dates back to 1580 and I found this online:-
This expression, which began as a translation of a term used by the French essayist Michel de Montaigne in 1580, alludes to gambling by candlelight, which involved the expense of illumination. If the winnings were not sufficient, they did not warrant the expense. Used figuratively, it was a proverb within a century.