It is important to remember that English spelling does more than just spell units of sound. It also spells units of meaning. Thus, for instance, the meaningful base sign
is spelled the same in design, disignation, signs,
even though it has a different sound in each of the four words. Modern English spelling also tries to show the historical sources of words that it borrows from other languages, which is illustrated nicely with the word pharmacy
The initial <ph> in pharmacy comes from its Greek source, which was spelled with the initial letter phi, which was transliterated into Latin and some other languages as <ph>. In some languages pharmacy was respelled with an initial <f> to make it more consistent with the languages’ spelling systems. For instance, in Spanish and Italian it is still spelled with an initial <f>. English borrowed the word from Old French, in which it was spelled with an initial <f>, which is how it was spelled in English in the 14th and 15th centuries. But then in the 17th century, a time during which a number of English words were respelled to show their classical Greek and Latin sources, it began to be spelled with an initial <ph> as it was in Latin.
The sound [f] is spelled <ph> about 12% of the time in English. It is the fact that English tries to spell all three – sounds and meanings and sources – that makes English spelling as complicated as it is.