The idea of a ship as a feminine presence has become embedded in maritime tradition but the reason for it is cloudy. Some sources suggest it's because the Latin word for ship, "navis" is feminine, but this doesn't hold water. We get the word "table" from the Latin word "tabula", also feminine, yet we don't think of a table as a "she".
Far more plausible is the concept of "she" with its connotation of motherhood, and therefore protection, a desirable characteristic in a vessel. There's irony in this since the presence of a real woman on board a ship was considered bad luck in times long past, although this might have more to do with the distraction a woman might cause to the male sailors on board.
In fact, the English language gets the word "ship" from the Middle High German "schiff", and that's a neuter noun. This romantic tradition is changing. Since 2002, Lloyd's List, which began reporting shipping news since 1734, has referred to all vessels as "it", and many news sources have adopted this new convention. Happily, most sailors have not.