1. Masculine Haqeeqi i.e. Real, which is used to denote the masculine gender in humans, animals.
2. Masculine Majazi i.e. Unreal, wherein it is used as Masculine but in reality it is not so e.g. (Angels) Malak, Layl (Night), Bab (door). The word Allah (swt), too falls in the second category i.e. Masculine Majazi.
The English language has got three genders; male, female and neutral. So if we translate the Arabic word 'huwa' into English, it can be translated as 'he' or 'it'. And the Arabic word 'hiya' can be translated as 'she' or 'it'.
Allah (swt) is unique and cannot be referred as 'it' in English, since Allah (swt) has no gender, neither male nor female or neutral.
Some people may argue that the Arabic word 'huwa' and 'hiya' both can be used for 'it' or neutral gender, then why Allah has used 'huwa' and not 'hiya' ?
In Arabic grammar there are certain rules and criteria for feminine gender. First, if it is female by nature, like the word mother (ummum), it becomes feminine in gender. Allah is not a female. Second, if it ends with the third Arabic letter 'ta' like 'mirwahtun' (fan), it becomes feminine. The Arabic word 'Allah' doesn't end with 'ta' so it cannot be feminine. Third, if the word ends with 'Alif Mamduda' (big Alif), it becomes feminine. But the Arabic word 'Allah' doesn't end with 'Alif Mamduda' so, it cannot be feminine. And lastly, if the object occurs in pairs, like pairs of the body, e.g. 'Ainun' (eyes), 'yadun' (hands), they are considered feminine. But Allah (swt) says in the Glorious Qur'an in Surah Ikhlas, chapter 112, verse 1"
"Say: He is Allah the ONE and Only;"
So Allah (swt) is one and not a pair. Therefore, by default since it cannot be used as 'Hiya' i.e. she or it, Allah (swt) uses huwa i.e. He. And Allah (swt) knows the best.