now in English usually representing "f," originally it was the combination used by Romans to represent Greek letter phi (cognate with Sanskrit -bh-, Germanic -b-), which at first was an aspirated "p," later the same sound as German -pf-. But by 2c. B.C.E. had become a simple sound made by blowing through the lips (bilabial spirant).
Roman "f," like modern English "f," was dentilabial; by c. 400, however, the sounds had become identical and in some Romanic languages (Italian, Spanish), -ph- regularly was replaced by -f-. This tendency took hold in Old French and Middle English, but with the revival of classical learning the words subsequently were altered back to -ph- (except fancy and fantastic), and due to zealousness in this some non-Greek words in -f- began to appear confusedly in -ph-, though these forms generally have not survived.