History: Where did 'An apple a day keeps the doctor away' come from?

And is it even true?

An apple a day keeps the doctor away. We’ve all heard it, that apple-based adage our parents convinced us of in a last-ditch attempt to get some roughage in our diets.