There is no definitive source for this. As so often, there are several theories. One is that it derives from the translation by jazz musicians of the Manzana area as 'apple orchard'. Another explanation has it that jazz musician's slang for engagement was 'apple' and that a date in New York was the 'big apple'. The phrase was certainly current in jazz music circles in the 1930s.
Probably the strongest contender is that it was coined in the horse racing community in the southern USA. John J. Fitz Gerald was a horse-racing writer for the New York Morning Telegraph in the 1920s. He reports hearing the phrase used by stable lads while on a visit to New Orleans in 1920, although there's nothing in that report to link the phrase to New York.
Fitz Gerald did later use the phrase with reference to New York in his 'Around the Big Apple', piece for the Telegraph on February 18, 1924, and that is the earliest citation we can find of it in print:
"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."
So, by his own account, Fitz Gerald didn't coin the phrase, but it's likely that he set it on its course to become part of the language.