If you know Latin and the word is of Latin origin, then it's generally possible to predict. As the RAE went modifying the orthography, while stressing etymological spellings, they recognized that some non-etymological spellings were so ingrained in society that it would be pointless to try to revert them.
So with that in mind...
Between y and ll
ll has its origins in double consonants, either intervocalic ll (bella), or word initial cl (llave, llamar), fl (llama as in fire) and pl (lleno). Notice many of these have duplets in the language due to later reimportation from Latin (clave/llave, pleno/lleno).
y comes out of Latin j or i (which were the same letter anyways).
Between j, g, or x
j comes out of Latin consonant clusters with an /s/ such as x (dijo) or ps (caja), the semivowel /j/ (like jota or in combination with certain consonants as in mujer), and come sibilants (rojo). The consonants clusters developed into sibilants along the way hence they end up j (from dixit to dijo we went /ks/ to /ʃ/ to /χ~h/)
g for Latin g or intervocalic c (agua)
x purely for etymological reasons almost exclusively in prefixes and retains its /ks~gs/ sound intervocalicly and in some dialects /s/ in front of consonants, or words that were lexicalized early on, intervocalicly, the sound change for the /ks/ cluster took hold, giving words like ejemplo
If the word is not of Latin (or Greek, for some cases of x), then if you know the language the word came from, you may be able to guess it, but those rules will be based on particular conventions between Spanish and that language (and more specifically, Spanish of the time the word entered and that language from the time the word entered).