At first I thought it was because New York was more accessible to the Navy but Boston is also on the coast
The answer is actually fairly straight forward. The Continental Army managed to get artillery on the Dorchester heights above the city. Henry Knox and his men hauled them overland from Fort Ticonderoga to Boston. The position of the guns threatened the Navy in the harbor and was above the range of heavy guns on the ships. The British considered contesting the heights but the Americans outnumbered them by this point and there was a heavy snow storm. The British decided to leave, and pledged not to torch the city if the Americans didn't fire on the ships while they embarked.
The situation in New York, with two large rivers on both sides of the city and the Americans unable to prevent British landings in force, was quite different.