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).