according to wiktionary, they both originate from Arabic اَلزَّهْر (az-zahr, “the dice”). presumably frenchmen were simply wont to add a bunch of silent letters.
The "h" is necessary to indicate there is no liaison with the previous word and the "d" is an indication that that derivative words use a non-silent "d" (like "hasardeux").
Zar in Balkan languages – it exists in e.g. Romanian and Albanian as well – is an Ottoman-era loanword from Turkish, which in turn borrowed it from Perso-Arabic (i.e. possibly directly from Arabic, but more likely through Persian mediation).
which looks like 'hazard' in english, which is (from mw dictionary)
* a source of danger
* the effect of unpredictable and unanalyzable forces in determining events : chance, risk
* a chance event : accident
* a golf-course obstacle (such as a bunker or a pond)
* a game of chance like craps played with two dice
i'd guess there's a connection? i'm no word historian person though...
According to the Oxford Dictionary, the origin of hazard is as follows:
Middle English (in hazard (sense 3 of the noun)): from Old French hasard, from Spanish azar, from Arabic az-zahr ‘chance, luck’, from Persian zār or Turkish zar ‘dice’
It bears mentioning, as an interesting fact that I just found about, that azzahr comes from Andalusi Arabic, and that zahr (in Arabic) means 'flower', from which the Spanish word azahar (the white flower on some trees such as orange trees) comes.
Etymologies from the most official Spanish dictionary:
azar: Del árabe hispánico *azzahr, y este del árabe zahr 'dado'; literalmente 'flores'.
azahar: Del árabe hispánico azzahár, y este del árabe clásico zahr 'flores'.
In Italian "gioco d'azzardo" has the exact same meaning as "juego de azar". But an "azzardo" is a dangerous or risky behavior or action (the implication being that doing it would be a gamble).
The Spanish pronunciation of orthographic z as /θ/ is rather late, post-16th-century. So, I would presume that French could have borrowed the word earlier than that.
I believe it was /ts/ and /dz/ before that, depending on if Old Spanish had ç or z. It's not like it went from [s] to [θ], which I think is what some people assume.
Wikipedia for Old Spanish says there were two distinct variants of z:
The affricates /t͡s̻/ and /d͡z̻/ were simplified to laminodental fricatives /s̻/ and /z̻/, which remained distinct from the apicoalveolar sounds /s̺/ and /z̺/ (a distinction also present in Basque).
That's pretty interesting. I don't have any experience distinguishing between sounds like that but reading around I start to wonder if I might produce such differences without being aware of it.