So a couple things:
1. Technically speaking, King’s Landing isn’t a harbor. A harbor is a deep body of water along the coast that ships can dock at, that’s protected from the winds and waves. King’s Landing is a riverrine port, with its docks in the Blackwater Rush, as opposed to out on the bay itself. (Compare the geography of King’s Landing to say, Volantis or Braavos)
2. According to WOIAF, it seems largely due to political disunity: “in the days of the Hundred Kingdoms, many petty kings had claimed dominion over the river mouth, amongst them the Darklyn kings of Duskendale, the Masseys of Stonedance, and the river kings of old…Towers and forts had crowned the three hills at various times, only to be thrown down in one war or another. Now only broken stones and overgrown ruins remained.” As a result of war, therefore, King’s Landing remained undeveloped and you didn’t get enough of a concentration of people necessary to attract trade.