Why does the Quran refer to Allah using the masculine pronoun, "he", rather than the feminine pronoun, "she"?
In the Name of Allah, Most Gracious, Most Merciful
[This answer was originally posted as a response to a student question in the course, The Pearl of Divine Oneness (BLF201)]
In the Name of Allah, Most Merciful and Compassionate
1. Grammatical and Natural Gender
Linguists distinguish between natural gender and grammatical gender. Natural gender is determined by physiology: an animal with a male sex organ is naturally masculine, and an animal with a female sex organ is naturally feminine. 
Grammatical gender is determined by language convention, not physiology. To clearly understand the distinction between natural and grammatical gender, one must examine languages like French or Arabic, where nouns are always grammatically masculine or feminine, even when they don't have a natural gender.
Chaise (French for "chair"), for example, is grammatically feminine, hence one refers to it with the same pronoun that one uses for "Marie" or "Fatima", i.e., elle (French for "she").. Kursiyy (Arabic for "chair"), however, is grammatically masculine, so one refers to it with the same pronoun that one uses for "John" or "Ahmed", i.e., huwa (Arabic for "he").
The distinction between natural and grammatical gender is blurred in English because words are only grammatically masculine or feminine if they are correspondingly naturally masculine or feminine. When a word doesn't have a natural gender—like "chair"—it is grammatically neuter and one refers to it with the neuter pronoun, "it", not the masculine pronoun "he", nor the feminine pronoun "she".
The presence of the neuter gender in English and its absence in Arabic (or French) causes linguistic mismatch. A consequence of this mismatch is that in English, if one uses the masculine or feminine pronoun to refer to something that is without natural gender, one is representing the thing as a person, usually for powerful rhetorical effect. This rhetorical device is called personification, and is often used by poets.  William Wordsworth, for example, wrote,
In thoughtless gaiety I coursed the plain,
And hope itself was all I knew of pain;
For then, the inexperienced heart would beat
At times, while young Content forsook her seat,
And wild Impatience, pointing upward, showed,
Through passes yet unreached, a brighter road ... 
Languages like Arabic, though, have no neuter gender, and such masculine or feminine pronominal references carry no connotations of humanness. The femininity of shams (Arabic for "sun") or the masculinity of qamar (Arabic for "moon") is grammatical gender based purely on language convention. It is normal and expected, in other words, to refer to shams with hiya (Arabic for "she"), and to qamar with huwa (Arabic for "he").
If inferring personification from this language conventions is a mistake, inferring misogyny is plain contradiction, for the feminine shams is greater than the masculine qamar. The great Muslim poet, Mutannabbi, wrote,
wa ma al-ta'nithu li ismi al-shamsi `aybun
wa la al-tadhkiru fakhrun li al-hilali
Neither is femininity a defect for the word, shams,
nor masculinity a pride for qamar 
The Quran refers to Allah using the masculine pronoun huwa because the word "Allah" is grammatically masculine, not because Allah is naturally masculine (Allah be our refuge). In English, using "He" for something without natural gender connotes personification, but not in Arabic. There is no implied anthropomorphism whatsoever. Neither, as explained above, is there any trace of misogyny.
3. Divine Transcendence
To affirm a natural gender for Allah Most High flatly contradicts the clear Quranic verse, "There is nothing whatsoever like unto Him." (Quran, 42:11) If this is plain for Muslims, it is confusing for others, not merely because purely grammatical masculinity is alien to the English mind, but also because no religion besides Islam affirms divine transcendence with such force.
Christians, for example, imagine that the Prophet Jesus (upon him be peace) himself was God (Allah be our refuge!) and the Prophet Jesus (upon him be peace) was a man. Feminist thought was born in predominantly Christian societies, where speaking of God as "He" confirmed the biologically masculine God of the Trinity. Modern feminist arguments for gender-neutral references to God are reactions to the masculine portrayal of God in Christianity.  Polytheism, too, anthropomorphizes its gods. Idols everywhere inevitably assume human or animal form, and humans and animals are both biologically gendered. With the exception of Islam, every religion that believes in a personal god anthropomorphizes its deity to some extent. Absolute divine transcendence requires tawhid (pure divine unity), and the only religion of tawhid is Islam.
To a Muslim who is grounded in the transcendent tawhid of Islam, ascribing biological gender to God is unimaginable heresy. The great jurist and theologian, Imam al-Tahawi, wrote in his celebrated creed,
He is exalted beyond limits, ends, parts, limbs and instruments, and—unlike all created things—the six directions do not encompass Him. 
Whoever ascribes any human attribute to Allah has disbelieved. Whoever understands this will take heed, refrain from speaking as the disbelievers do, and know that Allah’s attributes do not resemble those of humans. 
Allah Most High does refer to Himself in the Quran using the masculine pronoun huwa, but this is in the context of an uncompromising Quranic transcendence. He says, "There is nothing whatsoever like unto Him." (42:11) And Surat al-Ikhlas, one of the first suras memorized by Muslim children everywhere, reads, " Say, “The truth is that Allah is One. Allah is Besought of all, needing none. He begot not, nor was He begotten. And like Him has never been any one."" (Quran, 112:1—4) In this context, the masculinity of huwa with respect to Allah is unmistakably a purely grammatical masculinity without even a hint of anthropomorphism.
If huwa here implies no anthropomorphism, then neither would hiya. Why, then, choose huwa over hiya?
By convention of the Arabic language, grammatical masculinity is the norm, and grammatical femininity is the exception. Since most words are grammatically masculine, the expected grammatical gender of the word Allah is masculinity. 
There may, however, be a deeper wisdom. When I asked my teacher Shaykh `Abdul Karim Tattan (Allah preserve him) this question, he told me that the Quran normally mentions destructive winds of punishment in the singular—rih—and gentle winds of rain in the plural—riyah. The singular rih is grammatically masculine, but the plural riyah is grammatically feminine.  Masculinity connotes powerful majesty, femininity connotes gentle mercy. 
Our primary relationship with Allah Most High is worship: "I created men and jinn for aught but to worship Me." (51:56) Worship is the realization of the servant's utter neediness before the Master's complete majesty (just imagine the prostration position). Like the powerful winds, the grammatical masculinity of the word Allah connotes majesty that helps us realize our servanthood to our Lord. 
Feminist insecurities over the use of the pronoun "He" for Allah Most High stem from three mistakes.
The first is imagining that huwa in Arabic carries the same biological connotations that "he" does in English. Whereas the masculine pronoun carries definite biological connotations in English, it does not in Arabic because Arabic has no neuter grammatical gender, and all nouns are either grammatically masculine or feminine.
The second is an anthropomorphic conception of God. Whereas every other religion is marred by anthropomorphism, in whose context a masculine pronominal reference connotes the masculinization of God, the transcendent tawhid of Islam considers it disbelief to ascribe human likeness to God.
The third is wrong perspective. Whereas a humanist perspective makes indignant demands of God, the humble perspective of slavehood uses the grammatical masculinity of the word "Allah" to find peace in worship of its majestic Master.
And Allah Most High knows best.
 Grammarians of the Arabic language make a similar distinction. One of the earliest Arabic lexicographers, Ibn Sidah, quotes Abu `Ali al-Farisi, "A feminine thing is a living thing that has a female sex organ (i.e., the opposite of a masculine thing). This is femininity of meaning ... There are two kinds of femininity: femininity of meaning and femininity of wording." (Ibn Sidah, al-Mukhassas, Abwab al-mudhakkar wa al-mu'annath) Femininity of meaning corresponds to natural femininity; femininity of wording corresponds to grammatical femininity.
 This wasn't always the case. Old English, like Arabic and French, had no neuter gender. As the neuter gender became more common, the use of masculine and feminine pronominal references for things without natural gender increasingly connoted personification. The Oxford English Dictionary (OED) comments on the gradual incorporation of the neuter gender over centuries, saying, "It is not easy to say when grammatical gender ceased to be used, this differing according to dialect." The OED then quotes masculine pronominal references to inanimate things from the 13th to the 19th centuries. (The Compact Edition of the Oxford English Dictionary, (Oxford University Press, 1971) 1.1269)
 William Wordsworth, An Evening Walk. Wordsworth has personified the abstractions of content and impatience, referring to the former with the feminine personal pronoun, "her".
 This couplet is popularly cited. My quick search of Mutanabbi's Diwan didn't locate it, but it's quoted, for example, by al-Tha`alibi in Yatimat al-Dahr and by many other authors in their works.
 Abdal Hakim Murad has an excellent discussion of this in his article, Islam, Irigaray, and the retrieval of gender, available at http://www.masud.co.uk/ISLAM/ahm/gender.htm
 Abu Ja`far al-Tahawi, al-`Aqida al-Tahawiyya, Section 7 (unpublished translation by Hamza Karamali).
 Abu Ja`far al-Tahawi, al-`Aqida al-Tahawiyya, Section 5 (unpublished translation by Hamza Karamali).
 "Nouns are masculine by default and femininity is secondary." (Ibn Sida, al-Mukhassas, Abwab al-mudhakkar wa al-mu'annath)
 Non-human plurals in Arabic are grammatically feminine.
 Ibn Kathir cites Ibn Abi Hatim's chain of transmission to the Companion `Abdullah Ibn `Umar that he said, "There are eight kinds of wind: four of them are mercy, and four are punishment. The winds of mercy are the nashirat, the mubashshirat, the mursalat, and the dhariyat. The winds of punishment are the `aqim, the sarsar (these two are on land), the `asif, and the qasif (these two are on sea)." (Ibn Kathir, Tafsir Ibn Kathir, Commentary on Quran, 30:51) The italicized Arabic adjectives are all Quranic adjectives for various kinds of wind. The adjectives for winds of mercy are all feminine plurals, and the adjectives for winds of punishment are all masculine singulars.
 Abdal Hakim Murad explains how certain rhetorical connotations of femininity are also used to describe Allah Most High. He says, "In fact, by far the most conspicuous of the Divine Names in the Qur'an is al-Rahman, the All-Compassionate. And the explictly feminine resonances of this name were remarked upon by the Prophet (s.w.s.) himself, who taught that rahma, loving compassion, is an attribute derived from the word rahim, meaning a womb. (Bukhari, Adab, 13) The cosmic matrix from which differentiated being is fashioned is thus, as in all primordial systems, explicitly feminine; although Allah ‘an sich’ remains outside qualification by gender or by any other property." (Abdal Hakim Murad, Islam, Irigaray, and the retrieval of gender, http://www.masud.co.uk/ISLAM/ahm/gender.htm