For my DD10, I believe that her inability to spell comes from a lack of automaticity. When she writes, she may have the correct spelling and 2-3 other phonetically correct spellings of the same word in the same passage. She can't copy with any accuracy either. So, she could be asked to rewrite something, fix all of her spelling errors but then make errors in the words she previously spelled correctly. It has gotten better over time but never truly goes away. My husband is the same way. Spelling is still a challenge for him. Correct spelling is in his head but he can't always distinguish it from incorrect spelling that is phonetically the same.
There is a great passage about this in the Shaywitz book on Overcoming Dyslexia. I don't have it in front of me and my paraphrasing will not do it justice but here goes. Using fMRI technology, they figured out that dyslexics don't use the automatic word form area of their brain when they are reading/writing. Instead, they use multiple other areas of the brain to read/write. Their brains literally process language differently. This lack of automatic word form may be the root of their spelling issues.