It's pretty silly. But then, this question has been left unanswered since preschool. English clearly defines an alphabet 'F'. So why is a 'Ph' used ? or a 'Gh' in words like 'Enough' or 'Tough' ? It is pretty basic and elementary.
"Ph" is most commonly used in words that come from Greek, like "philosophy". The Greek letter that makes the "F" sound is "phi", written like φ.
As for "Gh", most of the words containing it come from German and old English. It was pronounced then as "ch" is in German today - as a rasp in the back of the throat, like the "ch" in "Loch Ness". Nobody really knows why, but around the same time that vowels shifted and English spelling was regularized, the "gh" sound was removed from English entirely. In some cases, it was just made silent (knight, sigh), and in some others it changed into a lot of different sounds. Now it's just one of the exceptions learners - both foreign and native - have to live with.
This has to do with traditional spelling that could mirror, or attempt to mirror, the spelling used by the language the word was borrowed from ("ph" is, in the vast majority of cases, indicates Greek origin coupled with Latin abuse and, sometimes, the Norman French delivery service);
[let's take a breath]
or, should the word be Anglo-Saxon to begin with, the original pronunciation plays a huge role. -gh- stands for the hard "h" used in some Germanic languages (for instance, it is the last sound in the name Heinrich). The hard "h" went to where the woodbine twines centuries ago, but the spelling persists, and we're reluctant to change it because it's dear to us.
The explanations above are correct; however, I would like to add that some of the spellings such as the "gh" in words like "night" occur because of obsolete letters in English now. If I recall, the letter yogh was used in this situation and others with "gh", but that letter is now obsolete. It did look like the letter "g" today, so when the printing press came out, they replaced it with "g".