It’s an interesting question.
The phrase was in common use in the 1970s.
The most commonly-cited origin is that the “apples” in question were actually small Word War I-era bombs or grenades and the expression was a taunt against the enemy.
On one hand, the n-gram analysis doesn’t seem to support the WWI theory — at the very least the phrase never made it into print the way that other war terms seem to have. You cite the expression “How about them apples”:
On the other hand, the earliest usage I can find does relate to WWI timeframes, in particular this quotation from a book called History of Company A, 307th Engineer Regiment, 82d Division, United States Army from 1919. This section of the document, called “Company Reminisces”, appears to be a collection of recollections, sayings, and inside jokes from the referenced Army unit: