The story
Popularized by John J. Fitz Gerald in horse-racing articles in the 1920s - an apple being a treat for a horse, and New York being a prize location for horse-racing at the time. From usage among African American stable hands. See the Wikipedia article. The Big Apple. The dream of every lad that ever threw a leg over a thoroughbred and the goal of all horsemen. There's only one Big Apple. That's New York.
Etymology from Wiktionary, CC BY-SA 4.0.