In the first place, it’s not f, but long s.
It was just a different way of writing s. It was always pronounced as an s is pronounced; it was never pronounced as an f. Its history explains the letter pretty well. Long s:
The long-s originated at a very early date in cursive Roman scripts, and can be seen in both Old Roman Cursive (1st to 3rd centuries AD) and New Roman Cursive (late 3rd century to 7th century).
("The Long and the Short of the Letter S", by Andrew West, BabelStone Blog)
It’s no longer used in today’s English. One reason it’s no longer used is because:
“The death knell,” he writes, “was finally sounded on September 10th 1803 when ... The Times newspaper quietly switched to a modern typeface with no long s or old-fashioned ligatures (this was one of several reforms instituted by John Walter the Second, who became joint proprietor and exclusive manager of The Times at the beginning of 1803).”
This may have been due to the fact that:
Long ‘s’ fell out of use in Roman and italic typography well before the middle of the 19th century; in French the change occurred from about 1780 onwards, in English in the decades before and after 1800, and in the United States around 1820. This may have been spurred by the fact that long ‘s’ looks somewhat like ‘f ’ (in both its Roman and italic forms), whereas short ‘s’ did not have the disadvantage of looking like another letter, making it easier to read correctly, especially for people with vision problems.
("The Gradual Disappearance of the Long S in Typography", Jeremy Norman's HistoryofInformation.com)