From Wikipedia:
Writer Bill Finger, on the naming of the city and the reason for changing Batman's locale from New York City to a fictional city said, "Originally I was going to call Gotham City 'Civic City'. Then I tried 'Capital City', then 'Coast City'. Then I flipped through the New York City phone book and spotted the name 'Gotham Jewelers' and said, 'That's it,' Gotham City. We didn't call it New York because we wanted anybody in any city to identify with it."[1]
"Gotham" had long been a well-known nickname for New York City even prior to Batman's 1939 introduction,[2] which explains why "Gotham Jewelers" and many other businesses in New York City have the word "Gotham" in them. The nickname was popularized in the nineteenth century, having been first attached to New York by Washington Irving in the November 11, 1807 edition of his Salmagundi,[3] a periodical which lampooned New York culture and politics. Irving took the name from the village of Gotham, Nottinghamshire, England, a place that, according to folklore, was inhabited by fools.[4] The village's name derives from Old English gat 'goat' and ham 'home', literally "homestead where goats are kept",[5] and is pronounced "goat 'em", /ˈɡoʊtəm/ goat-əm (c.f. Chatham, /ˈtʃætəm/ chat-əm, a similar name which has not undergone a t → th pronunciation shift). In contrast, "Gotham" as used for New York or in the comics is pronounced /ˈɡɒθəm/ goth-əm,[6] like the word Goth.
In Detective Comics #880, the Joker mentions to Batman that Gotham means "heaven for goats".