Catholic perspective here:
The short answer is that the Holy Spirit, like all of the Persons of the Trinity, does not have a physical sex, because God in His Divine Nature does not have a body. (See Catechism of the Catholic Church [CCC] no. 370.)
In different languages, the grammatical gender will follow the gender for “Spirit” (in Greek, τὸ Πνεῦμα, neuter; in Latin, Spiritus, masculine, which is followed in most of the Romance languages; etc.)
In English, which does not have strong grammatical genders, we should use the pronoun that best describes the fact that the Holy Spirit is a Divine Person. Using “It” would suggest that the Holy Spirit is impersonal; using “Her” would probably give rise to a lot of confusion (because the procession of the Holy Spirit is really quite unlike any relation among creatures); so it is best to use “He.”
Gender vs. sex
From a philosophical point of view, we must distinguish between gender and sex. Gender is strictly speaking a grammatical notion, that governs the agreement of articles and adjectives with a given noun. In Western languages, there are at most three grammatical genders: masculine, feminine, and neuter (Latin for “neither one”). When the concept talked about has a physical sex, the grammatical gender generally follows it, but otherwise, the gender is often quite arbitrary. (For instance, in Spanish, salt, or “sal,” is feminine, but in French and Italian, “sel” and “sale” are masculine.)
On the other hand, sex—the maleness or femaleness of a human being or animal—is a physical or ontological reality that transcends mere grammar, and has its roots deeply in the human’s or animal’s bodily configuration. (For an overview of the Church’s view on sex, see CCC 369-373; for instance, the Church does not subscribe in any way to gender theory.)
God does not have a sex, but He revealed Himself as Father.
God is, as I noted above, by nature pure spirit, so He does not have a physical sex.
He did, however, choose to reveal Himself generally using masculine references. For example, in the Old Testament, He is clearly the “Lord” (Adonai, which is masculine), and He reveals Himself as Father. He has qualities that are typically those of a mother, such as compassion (racham, literally the “womb”), but the Israelites clearly referred to God as “He,” and Jesus continued that practice.
It is true that Wisdom is personified as a feminine figure (e.g., in the Proverbs), but it is important to recall that the Israelites knew nothing about the Holy Trinity until Jesus revealed it to them, so they did not intend to identify Wisdom crassly with any one of the Persons.
In the New Testament, it became more explicit: God, the Second Person, became incarnate as a male, and the Son continued to refer to the First Person as the “Father” (never once as the “Mother”). This revelation is not accidental, and although God in His Nature has, of course, all of the perfections that are particular to men and women, He specifically wished to be revealed as Father. (Or, said in a different way, human fatherhood renders visible to us a fundamental aspect of our relationship to God; in particular, the fact the He wants to make us His sons and daughters; see CCC 238-242 and 2779-2793.)
The gender of the Holy Spirit
In languages with a true grammatical gender, the gender of the Holy Spirit will depend on the pre-existing gender of the word Spirit, as I noted above.
In languages, like English, with only a weak grammatical gender, the gender that best characterizes the Holy Spirit as the Third Person of the Trinity should be used.
“It” would, as mentioned, imply that He is impersonal; “She” would likely cause confusion regarding our relationship to God (which does not depend on the Persons, but on the Essence of God); so, the best pronoun to use is “He.”