I think John Mace’s point is that, while the letter “h” does help to distinguish homophones, it wasn’t inserted into or retained in the written language for that reason; it originally existed in those words for reasons relating to actually contrastive pronunciations, and remains in those words out of the same inertia of spelling that affects most words, rather than any conscious attempt to keep homophones from becoming homonyms.
The OP asks “Why do they use “h” at all?” While the origin may have been due to pronunciation, it most likely has been retained because of the spelling distinction. Spanish is extremely aggressive in its insistence that orthography conform with pronunciation. Unlike English or some other languages, loan words are almost always spelled according to their Spanish pronunciation, and that often extends to foreign proper names. I think silent ‘h’ would have been eliminated long ago if it were merely an artifact of former pronunciation.
Diceman, does it strike you as odd that English retains the letters Q and X? Neither has a “primary” phoneme of its own, and the single possibilities for each (voiceless uvular plosive for the former, voiceless velar fricative for the latter) do not occur in Modern English. For that matter, one might argue either that K is redundant with C (since the latter was used to spell the voiceless velar plosive before the former), or that, since C’s use both for that and for the voiced alveolar siblant (as in cease) renders it ambivalent, C should be only used in the voiceless affricate ch, as in church. And then you’d want us to abandon the H in that construction. And then you’d want to change the spelling of, for instance, either then or thin. And then you’d wonder about the first vowel sounds in *wander *and wonder, and that would lead you to wanting to rejigger wind as in breeze and wind as in twist about, and…
Well, you get my point, I hope. Orthography remains as it is because of inertia as much as for any other reason. Changing spelling suddenly results only in confusion and chaos.
And there are many inertial spellings in English, arguably many more than Spanish. A neat and clean example is the digraph “gh” - in the middle ages it represented the gutteral sound that is represented by the Greek “x” and the German “ch”. “Light” is cognate with German “licht”, and used to sound a lot closer to it. Other words with the silent “gt” are bright, height/high (compare German “hoch”), sight, night (compare German “nacht”), sleight, right, plight, and flight (compare German “flucht”). Eventually people stopped pronouncing the “gh” but continued to spell it the way they always had. Nowadays the “gh” phoneme isn’t even a part of most English accents/dialects and many English speakers drop the “gh” in loanwords like “chutzpah”. Also, I believe that many if not all silent terminal "e"s were originally pronounced.
This is true in English, but as I already pointed out it is relatively rare in Spanish. Orthography almost always represents current pronunciation rather than being an archaic holdover. (There are cases in which Iberian Spanish differs from Latin American in the pronunciation of certain letters such as ‘c’, but the correspondence between spelling and pronunciation holds well within each dialect.) Five hundred years ago the spelling of Spanish varied much more, but has since been regularized.
Somewhat ironically, although English spelling may have varied more in the past, it probably corresponded better with pronunciation. Those variant spellings were an attempt to reproduce the way the words actually sounded at the time. The divergence of spelling and pronunciation is a more recent development.
Well, it is merely an artifact of former pronunciation. Saying it’s retained because of the spelling distinction amounts to saying it’s retained because it’s there. Or rather, let me ask, what is the homophone from which disambiguation requires keeping the “H” in the OP’s “Hector”, or “hacienda”, “hombre”, “horchata”, “hermano”, etc.?