The story
“Homestead where goats are kept”, from Old English gāt (“goat”) + hām (“home”). * (New York City nickname): First used 1807 by Washington Irving in his Salmagundi Papers: see the quotation. The original pronunciation had /th/ with later loss of /h/. The pronunciation with /θ/ is a spelling pronunciation that arose from a misreading of th as a digraph.
Etymology from Wiktionary, CC BY-SA 4.0.