Since it's stupid, it originated in England. Am I right?
Actually.... it comes from tripartization of Indo-European....
Massive simplification: Proto-Indo-European (ancestor of both English and Polish) had different numbers of genders (noun classes) at different times
basically the oldest seems to have been a two-noun class system (common-animate, inanimate-neuter).
Later a third class evolved (the basis of the feminine gender in daughter languages) and this included, among other things intangible and/or abstract things (which is why abstract nouns are almost always feminine across the language family).
This tended to be unstable and different languages either collapsed this back into a dual system (Latinate, Celtic I think, Armenian (which maybe never had the third gender, Indic...) while others preserrved a tripartite divison (Slavic, Greek, Albanian, Germanic though some of them recollapsed into a two-class system)
Polish and some other slavic languages seem to be splitting the masculine gender in two: animate and inanimate (the latter of which will eventually probably be absorbed back into the neuter gender but.... that's a topic for another day.
The idea of noun-classes is so strong in Indo-European languages that some languages that seem to lose all distinctions end up acquiring new divisions. The division into countable (tree, car, child) and non-countable (water, information, love) of modern English is basically a reconstitution of gender/noun-classes. this parallels some dialects of Danish in which the gender system (common vs neuter has developed into a count-common and non-count-neuter distinction).
So.... remember when I said that nouns referring to intangible and/or abstract things went into the noun-class usually referred to as 'feminine'?
Remember when I referred to 'daughter' languages?
Referring to a ship or country as 'she' is a throwback to that, you're not referencing anything physical but an emotion related to it or the idea or spirit of it.
Clear?