'The devil' is often added to question-words such as 'what/how/who' etc in order simply to make them more emphatic. The earliest recorded example of 'how the devil' appears in a work of Caxton's published in 1489..."How the devil dare you thus speak?" So, it's been about for quite a while!