The 'a' is from the word 'cacao', which is the name of the tree and bean, and by all rights the proper name of the drink, except the 'ao' digraph is quite rare in English (quick, name 3 other English words that have it without cheating!), resulting in the swap to 'oa'. The pronunciation problem, on the other hand, comes from Samuel Johnson's famous Dictionary of the English Language, in which a printing error caused the entries for 'coco' (as in the palm tree/nut) and 'cocoa' to run together, which, coupled with the spelling change, confused the issue more or less permanently.