In Old English, nouns had masculine, feminine or neutergender. When using appropriate pronouns, these would be he, she and it, respectively. When that system broke up, 'it' was used as the pronoun to refer to all nouns. However, some things considered somehow especially masculine were still referred to as 'he' for a long time afterwards - eg mountains, oak-trees etc - and others were still referred to as 'she' - eg boats, carriages etc.
The use of 'she' for a ship, for example, is at least as old as the 14th century in ‘modern' English and it was the same in Roman times. This may have been because their ships were dedicated often to goddesses, who were possibly the first figureheads carved on ships' prows. Even before that, in the language of the ancient Babylonians, ‘boat' was a feminine word, just as it was in Biblical Hebrew. That means Noah's ‘ark' was a feminine word, as boat is today in Italian and Arabic. ( The French - typically! - have masculine ships and the Germans have neuter ones.) The answer to your question as to why ships are called ‘she' is, therefore, a combination of language-development and history.