The origin of this famous saying can be found in the following nursery rhyme:
An apple a day keeps the doctor away
Apple in the morning – Doctor’s warning
Roast apple at night – starves the doctor outright
Eat an apple going to bed – knock the doctor on the head
Three each day, seven days a week – ruddy apple, ruddy cheek
The simple meaning of this rhyme is to encourage children to eat healthily in order not to become ill.