I don't have a good answer for the question "Why does 'Why doesn't it work?' become 'Why does it not work?'” The shift is doubly intriguing if (like me) you don't see a compelling reason (beyond mere convention) why "Why doesn't it work?" couldn't be rendered as "Why does not it work?"
Though some other answerers here consider the wording “why does not it work?” to be ungrammatical, they haven’t explained in much depth why they take that view. Indisputably the phrase sounds awkward—perhaps because we are so strongly acclimated to the wording “why does it not work?” as the standard alternative to “why doesn’t it work?”—but from a purely grammatical perspective, I have trouble seeing how “why does not it work?” differs structurally from, say, “why does not it occur more often?” And if we deem all questions of the form “Why does not…” ungrammatical, how do we distinguish them from questions of the (slightly) simpler form “Does not…”? Or are the latter formulations, too, ungrammatical?
Ultimately, it seems to me, concluding that wording of the form “why does not” is ungrammatical would logically lead us to condemn a great many sentences that, though old-fashioned sounding, do not appear to break any fundamental rules of sentence construction and ready comprehensibility. Let’s take a look at some of the many historical instances of this wording.
In the 1600s and 1700s, writers not infrequently employed interrogative phrases such as “does not the,” “do not the,” “is not the,” and “are not the”—as a Google Books search for those phrases makes clear. From Izak Walton, The Compleat Angler, or the Contemplative Man’s Recreation (1653):
Piscator. Now, Sir, has not my Hostis made haste? And does not the fish look lovely?
From Richard Baxter, The Saints Everlasting Rest (1654):
Doth not this Load-stone snatch thy heart unto it, and almost draw it forth of thy brest? Canst thou read the history of love any further at once? Doth not thy throbbing heart here stop to ease it self? And dost thou not as Joseph, seek for a place to weep in? or do not the tears of thy Love bedew these lines?
From Thomas Hobbes, “Problems of Vacuum,” in Seven Philosophical Problems, and Two Propositions of Geometry (1662):
If there were empty space in the World, why should not there be also some empty space in the Vial before it was sucked? And then why does not the water rise to fill that, when a man sucks the Vial he draws nothing out neither into his Belly nor into his Lungs, nor into his Mouth ; only he sets the Air within the glass into a circular motion, giving it at once an endeavor to go forth by the sucking and an endeavor to go back by not receiving it into his mouth.
From John Tillotson, “The Prejudices against Jesus and his Religion consider’d,” in The Works of the Most Revered Dr. John Tillotson, Late Lord Archbishop of Canterbury (1717):
Whatever commendation may be given to any Art or Science, Men will question the Truth and Reality of it, when they see the greatest part of those who profess it, not able to do any thing answerable to it. The Christian Religion pretends to be an Art of serving God more decently and devoutly, and of living better than other Men ; but if it be so, why do not the Professors of this excellent Religion shew the Force and Virtue of it in their Lives?
From Thomas Rutherford, An Essay on the Nature and Obligations of Virtue (1744):
There is an unfit application made in giving pain to brutes; why then is not this a constant reason against every action, which gives pain to them? why does not it make every such action irrational and so unfit for a rational agent? Is it because the use we have of them and the advantages we receive from their pain is a stronger reason, which intervenes? Then why is not this reason from interest, which keeps us clear of any crime in killing or in hurting them, sufficient to make the same behavior towards our own species neither irrational nor wrong?
From Erasmus Darwin & Robert Waring Darwin, Zoonomia; or The Laws of Organic Life, volume 2 (1796):
If the torpor of the uterine veins, which induces the monthly periods of the catamenia, be governed by the increase of terrene gravitation ; that is, by the deficiency of the counter-influence of solar and lunar gravitation ; why does not it occur most frequently when the terrene gravitation is the greatest, as about six hours after the new moon, and next to that about six hours after the full moon?
Examples continued to appear commonly through the mid-1830s. From R.U. West, “on the Influence of the Nerves,” in London Medical and Surgical Journal (March 12, 1832):
And why does not it take place under all circumstances, for bodies always grow cold after death? Many physiologists contend that the blood in the venæ cavæ is propelled into the right auricle by the atmospheric pressure, in consequence of a vacuum formed there by its dilation.
But such expressions seem suddenly to have become much less common in the second half of the nineteenth century, for reasons unknown to me.
In a Google Books search for the phrase “why does not the” covering the three decades between 1978 and 2008, most of the matches come from books on economics, philosophy, ethics, and religion, perhaps because the diction sounds suitably old-fashioned and sermon-inflected. In any case, instances do still appear. Here are three instances. From Immanuel Wallerstein, “The Rural Economy in Modern World Society” (1975), published in The Capitalist World-Economy (1979):
I would phrase the intellectual questions of our time—which are the moral questions of our time—as follows: (1) Why is there hunger amidst plenty, and poverty amidst prosperity? (2) Why do not the many who are afflicted rise up against the few who are privileged, and smite them? You may note that I have affected the language of the King James edition of the Bible. I have done this to signal two things. At one level our problems are biblical ones, that is eternal ones, ones that confront all of human history. But at a second level, they take on a specifically modern form, of a world whose origins in the sixteenth are heralded precisely by this King James version—a new language for a new era.
From G.L.S. Shackle, Epistemics and Economics (1992)
If the term cycle is justified, everything essential to the cycle must be present in any ‘present moment’. Then the problem is, why do not all these composing elements resolve themselves at once, why does not 'the cycle' disappear through a single, comprehensive and immediate adjustment?
From Arthur W. Pink, The Attributes of God (2002):
And what of apostate Christendom, where every possible form of sin is now tolerated and practiced under cover of the holy name of Christ? Why does not the righteous wrath of Heaven make an end of such abominations? Only one answer is possible: because God bears with “much longsuffering the vessels of wrath fitted to destruction.”
A Google Books search even finds three instances of the phrase “why does not it work” in recent publications. From Consumer Energy Price Increases: Hearing Before the Subcommittee on the Consumer of the Committee on Commerce, Science, and Transportation (August 7, 1990):
Senator LIEBERMAN. If all this is true, then why does not it work in reverse? In other words, if the increase in the world price, because of expectations, because you are, planning to buy the coming supply of crude oil bids up the price? Why does not it work the other way when the world price drops, why does not the price go down?
From Ronald Finklestein, Celebrating Success! The Power of Attitude! (2003):
You give yourself permission to accept and express this good. Thank you spirit and so it is! So why does not it work all the time? Let me share with you some things that can conflict with you achieving you life's dream.
And from Nubar Sarafyan, The Action Principle and Evolution (2009):
But if this is true, then how can one explain the existence the huge gravity inside of the barred galaxies and black holes, where matter average density, obviously, is much less. Besides, if the gravity is the only condition of existence, then why does not it work in the limits of galaxy nucleus, wherein the energy huge transmission processes permanently take place.
These examples refute the notion that no one uses the wording “why does not”—even in the case of the awkward and decidedly unidiomatic “why does not it work.” Nor is it evident to me that the construction is illogical or fatally incoherent. It sounds a bit odd, certainly, and it’s relatively rare (which is probably why it sounds odd), but—if I may channel the voice of Senator Lieberman for a moment—why should not we view it as grammatically acceptable?