The story
The saying may come from Wales. In 1866 a magazine printed “A Pembrokeshire proverb”: eat an apple on going to bed, and you’ll keep the doctor from earning his bread. Other rhyming versions floated around for decades. The short, snappy one we know today was written down in 1913, in a book of country sayings.