It seems we owe this – along with so many other things in English – to Latin. The Classical Latin alphabet had fewer letters than we do today (for example U and V used to be one and the same), and Q was used as an alternative to C and K in certain situations. Latin orthography dictated that a Q should be followed by a U, and the habit stuck, making QU a common digraph.
In the earliest Latin inscriptions, the letters C, K and Q were all used to represent the sounds /k/ and /g/ (which were not differentiated in writing). Of these, Q was used to represent /k/ or /g/ before a rounded vowel (e.g. “EQO” = ego), K before /a/, and C elsewhere. Later, the use of C (and its variant G) replaced most usages of K and Q: Q survived only to represent /k/ when immediately followed by a /w/ sound.
The same “QU” rule is also present in other Romance and Germanic languages, such as French and Spanish.
Most words in English that have a Q that isn’t followed by a U are naturalized words from Arabic (e.g. faqir), Chinese (e.g. qi) and Hebrew (e.g. qaddish). Most of the others are acronyms (e.g. NASDAQ, Compaq, etc.).