In Spanish (and also in Latin, and most of Romance languages, too) the present subjunctive is formed by a kind of swapping the indicative endings between the verb declension classes: the 1st class (-a-) takes the indicative endings from the 2nd class (-e), and the 2nd and 3rd class (-i-) take the indicative endings from the 1st class:
QUESTION: Is it only coincidental, or is there something deeper behind it? Something like "as the subjunctive often expresses uncertainty, let's make the verbs sound weird by deliberately using a wrong set of endings to emphasize that we are not sure"?
It's clear that nowadays the endings are just inherited from the language history, but is there any theory about the origin of this particular coincidence?

As Spanish kept a small number of conjugation types (like most modern Romance languages) it may look like a swap to us. But Latin had five conjugation types.
According to this, Latin had just one thematic vowel of choice for the present subjunctive of all regular conjugation types. This vowel happened to be -a- but also happened to prove cacophonic in the 1st conjugation, which also had a thematic -a- of its own. The change to -e- in just that case had euphonic reasons.
– guillem Apr 21 '16 at 15:28