The double letters are to help in pronouncing the word. Let us say we have any vowel, followed by a consonant, then followed by a vowel: v c v.
The first vowel, by English phonetic rules, would be pronounced in its long form.
"vale", "male", "bale" - the 'a' is pronounced in its long form
However in "valley", the pattern is "v c c v" (vowel, followed by double consonant, vowel)
The 'a' in "valley", because of the double 'l', is pronounced like the 'a' in "hatch" or "mat".
This rule isn't always followed. English is sometimes contradictory. However, the double-consonant rule holds in almost all cases.