questions used to be asked along the lines of 'how in the devil's name [or God's name, for that matter] did he do that?' Because, I suppose, the English swear all the time - they have long been famous for it; medieval Frenchmen used to call them 'les goddams'. Anyway, your question is a slight variation on that: 'How are you?' with added swearing.
The earliest recorded use of the phrase "How the devil..." was from Caxton - he of printing-press fame - and published in the 1480s, so it's been around for a long time! The 'devil' idea was also attached to when, where, who, what etc questions to add a note of surprise, irritation, dismay and so on.
"How the devil are you?" indicates that the speaker is pleasantly surprised to see you.
In "How the devil are you", the devil is just added for emphasis, in this case reflecting, presumably, that fact that the speaker hasn't seen the spoken to for quite a while, or that something has happened to the spoken to which makes the question a real one, rather than a perfunctory or oratorical one. The speaker could also have said, "How the heck (How the hell) are you?" or any number of similar variations.