Why does the word colonel (as in military rank) have such a strange spelling compared to how it's pronounced (or vice versa, although I don't know how you would pronounce that)?
It comes from Italian military manuals, and the English spelling preserves the Italian form, colonnello. Two pronunciations coexisted; the r prevailed in English. Spanish took both the spelling and pronunciation: coronel.
As reported from the NOAD:
ORIGIN middle 16th Century: from obsolete French coronel (earlier form of colonel), from Italian colonnello (column of soldiers) from colonna (column) from Latin columna. The form coronel, source of the modern pronunciation, was usual until the middle 17th Century.
The word is pronounced in a strange way because it kept the old pronunciation, while the word changed spelling.
Colonel is written with l but pronounced the same as kernal (BE: /ˈkɜː.nəl/, AE: /ˈkɝː.nəl/).
How did this happen:
From borrowing the same word from two different places; Italian colonnello and French coronnel. In the 1500s, English borrowed a bunch of military vocabulary from French, words like cavalerie, infanterie, citadelle, canon, and also coronel. French had borrowed coronel from Italian:
Coronel: From Middle French coronel, from Italian colonnello (“the officer of a small company of soldiers (column) that marched at the head of a regiment”), from compagnia colonnella (“little column company”), from Latin columna (“pillar”), from columen, contraction culmen (“a pillar, top, crown, summit”), o-grade form from Proto-Indo-European *kʷel- (“going around”). [Wikitionary]
Why did colonnello change to coronel in French:
It's because of a phenomenon called Dissimilation. Dissimilation is a phenomenon whereby similar consonants or vowels in a word become less similar. It's particularly common in words that have liquid consonants (/r/ and /l/).
Dissimilation of /l..l/ to /r..l/:
An example where a relatively old case of phonetic dissimilation has been artificially undone in the spelling is English colonel, whose standard pronunciation is /ˈkɝnəl/ (with the r sound) in North-American English, or /ˈkɜːnəl/ in RP. It was formerly spelt coronel and is a borrowing from French coronnel, which arose as a result of dissimilation from Italian colonnello.
Dissimilation of /r..r/ to /l..r/:
The opposite process of the above happened with the Latin word peregrinus (pilgrim), when the first r was changed to an l. Now it’s peregrino in Spanish and Pellegrino in Italian. English inherited the l version in pilgrim.)
How the spelling 'colonel' prevailed:
After the dissimilated French coronel made its way into English, scholars of late 16th century started producing English translations of Italian Military treatises. Under the influence of the originals, people started spelling it colonel to conform with the Italian form. The spelling colonel had been standardised by the middle of the 17th century but the pronunciation with r was still popular and it prevailed eventually. (French switched back to 'colonel', I don't know why. Probably because of dissimilation.)
The 'o' in the second syllable was once pronounced but later on, the second syllable got syncopated.
That's how we got the idiosyncratic spelling and pronunciation.