Origins
The word 'harbor' (British English 'harbour') descends from Middle English 'herberwe' or 'herbour' (lodging, shelter, a protected place), from Old English 'herebeorg' (lodging, quarters), from Proto-Germanic *harjabergō, a compound of *harjaz (army, host, war band) and *bergō (shelter, protection, that which hides or covers). At its etymological core, a harbor is a place where an army takes shelter.
The first element, *harjaz (army), is the source of numerous personal names and place names across the Germanic world: 'Harry,' 'Harold,' 'Herbert' (bright army), 'Herman' (army man). It also produced Old English 'here' (army), which survives in 'Hereford' (army ford) and 'heriot' (a feudal death tax, originally the return of military equipment). The second element, *bergō (shelter), is related to the verb *berganą (to shelter, to save, to hide), which produced German 'bergen' (to rescue, to salvage) and survives in English place names like 'Canterbury' (the stronghold of the people of Kent).
The semantic development from 'army shelter' to 'any shelter or lodging' was complete by the Old English period. The further narrowing to 'a sheltered place for ships' developed during the Middle English period, as England's maritime identity grew and the need for a specific word for a ship's haven intensified. The broader sense of 'shelter' or 'lodging' faded from common use but left traces: the verb 'to harbor' (to give shelter to, to conceal — as in 'harboring a fugitive' or 'harboring resentment') preserves the original, non-nautical meaning.