We’re all accustomed to the many ways that the letter combination ‘ough’ is pronounced in English, depending on the word:
cough, rough, though, through, thought, Slough, and the whimsical hiccough.
But the letters -gh- by themselves are only pronounced in two ways here: /f/ and silent.
Originally -gh- represented the voiceless velar fricative, /x/, which now only remains in Scottish accents, and is represented there by -ch- (as in loch), although in Northern Ireland, loch is spelt lough, but the -gh- is pronounced /k/.
-gh- appears in many other words, not just as part of the -ough- complex. We find it also following -au-, as in laugh (/f/) and caught (silent, but serving to lengthen the preceding vowel). And following -ei-, as in weight, weigh, etc., it is always silent.
Elsewhere, it appears initially, sometimes to no purpose, as in ghost, and its relatives ghastly and aghast, but also in words borrowed from Italian, such as ghetto, where it serves, as in Italian, from which ghetto is borrowed, to make the -g- a plosive rather than an affricate. (This use should also help remind English speakers that Genghis Khan ‘ought to’ be pronounced /’dʒeŋɡɪs/ rather than /’ɡeŋɡɪs/ – consider the spellings of the name as it appears in transliterations of Central Asian languages: Chingiz, for instance).
This does not exhaust the possibilities. The loss of the velar fricative has allowed -gh- to represent all the remaining English voiceless fricatives, with the exception of /s/ (unless any reader can show me otherwise). Most commonly it becomes /f/, but in a single place name, Keighley, it has become /θ/: /ˈkiːθli/, and in the family name Greenhalgh, it all depends on the particular family which bears the name, sometimes /ɡ/, but at other times /ʃ/ or even the affricate /dʒ/, so /ˈɡrinhælɡ, -hælʃ, or -hældʒ/. And in Northern Irish, as noted above, -gh- represents /k/.
There is even one class of names in which I maintain that -gh- represents a vowel – in British English, schwa. The best known of these is Edinburgh, which in the English of England is pronounced /ˈedɪnbərə/. Americans generally pronounce this name with the final -gh pronounced as the ‘goat’ vowel.