Many Spanish words that nowadays begin with h- used to begin with f-, for example:
- hacer < facere (PT fazer, IT fare, FR faire),
- hijo < filius (PT filho, IT figlio, FR fils)
- haya < fagea (PT faia)
Can anyone explain this change?
How it exactly happened is unknown. The change itself is not really difficult to imagine. It's a frequent phonetic change in many languages.* One can say it's a kind of lenition (weakening): /f/ involves a well-marked friction between the lips and the teeth, while /h/ is considered by some to be less than a full fricative consonant (more like an approximant).
Why was /f/ prone to change?
All of these made it easy for /f/ to change its pronunciation. In some regions it seems that /f/ was pronounced [h] before posterior vowels (/o/ and /u/) and [ɸ] before the other vowels and consonants like /r/ and /l/. In some others, particularly in northern Castile (where modern standard Spanish comes from), it apparently changed to [h] everywhere. There are traces of this change already in the 9th century. Even then this [h] was disappearing, continuing a process that had already begun in Vulgar Latin.
The only place where /f/ (pronounced [hɸ]) was kept was before [w], that is, in words like fuego (< Latin focum). This would later revert to [f], as well as other words, generally borrowed from Latin or other languages as learned terms (cultismos).
*For a quick reference, check out Index Diachronica; this shows a list of documented instances of /f/ becoming something else in lots of languages (search the page for things like f → h and f → ɸ).