Are you asking where it comes from, or why it hasn't been replaced?
In the former case, it's because the Greek phi originally denoted a sound (an aspirated labial stop, to be exact) sufficiently different from the Latin F that the Romans felt it needed be treated differently when spelling Greek words in Latin letters. Only later did the sound change to an 'f' sound.
In the later case, because the anglophone world is extremely stubborn and conservative in matters of orthography. In many modern European languages, eg. Spanish and Swedish, 'ph' has been largely or wholly respelt as 'f'.