What is known about the nickname "The Big Apple" is given in the Historical Dictionary of American Slang, by J. E. Lighter, vol. 1, published in 1994.
There was a comparison made in 1909 of NYC to a "big apple" sucking all the sap from the tree that was the nation, but really it seems that the nickname originated in the world of horse-racing. The nickname first appeared in 1921, referring to the NYC racetracks as the big-time of horse racing -- at least, of horse-racing in the East. Later in the 1920s it was applied to the city itself and became fairly popular -- there was a dance craze in the mid 1930s called "The Big Apple". It became internationally familiar in 1971 when the image was picked up by the city's tourism bureau and made the basis of the bureau's logo -- the skyline in an apple outline.
A phony "organization" purportedly devoted to the history of NYC has put a bogus story on the Web tracing the name to a 19th century whore, but everything about that story and its sponsor stinks on ice.
George A. Thompson
Author of A Documentary History of "The African Theatre", Northwestern Univ. Pr., 1998.