Because /j/ (English y) is a palatal phoneme, and palatals are historically unstable. (See for example Nick Nicholas’ answer to Linguistics: In Indo-European languages using a Latin alphabet, what’s up with these two letters “ch” that are pronounced (phonetics) so differently?)
Rob Kerr’s answer is correct in principle, but the variation between German, English, French, and Spanish can all be traced to language change after the initial letter was assigned.
<j> started life as the Latin variant of <i> before vowels, which makes it [j] (English y). That’s the value it continues to have in German, and other Germanic and Slavic languages. So: [j]
/j/ underwent Fortition in Old French, and ended up pronounced as /dʒ/. So Jacobus in Latin (/jakobus/, from Hebrew Ya’aqov) was Jacques in Old French, which was pronounced /dʒakəs/, something like Jahkuss in English. And in fact, <j> is still pronounced that way in English, keeping the value that was introduced with the Normans. So: English [dʒ]
In Middle French, /dʒ/ changed to /ʒ/, but the spelling remained the same. Hence Jacques is now pronounced /ʒak/, Zhak. So: French [ʒ]
In Old Spanish, <j> was also pronounced /dʒ/, and also ultimately derives from Latin /j/. In the 16th century, Spanish went through a involved sequence of changes in their coronals (Phonological history of Spanish coronal fricatives), at the end of which <j> ended up pronounced as /x/, via /ʒ/ and /ʃ/.
So filius in Latin, “son”, went through the changes /filius/ > /filjo/ > /fiʎo/ > /fijo/, to end up as Old Spanish fijo, /fidʒo/. Then in Middle Spanish, it went /hidʒo/ > /hiʒo/ > /hiʃo/ > /hixo/ > /ixo/. So: Spanish [x]. (And an explanation for any <j> as /ʃ/ you might find.)
, MA in Linguistics from BYU, 8 years working in research for language pedagogy.