One of the earliest usages in English is in William Langland's poem Piers Plowman A. i. 161 "Fey withouten fait is febelore þen nouȝt, And ded as a dore-nayl", though it is unlikely this is Langland's invention. It also appears in the English William of Palerne l. 628 "For but ich haue bote of mi bale‥I am ded as dore-nail" and in the alliterative debate poem Parliament of the Three Ages "Dede als a dore-nayle doune was he fallen" 65. Both of these texts are of uncertain date, and may predate Langland's usage.
One plausible explanation is that doors were built using only wood boards and hand forged nails, the nails were long enough to dead nail the (vertical) wooden panels and (horizontal) stretcher boards securely together, so they would not easily pull apart. This was done by pounding the protruding point of the nail over and down into the wood. A nail that was bent in this fashion (thus not easily pulled out) was said to be "dead", thus dead as a doornail.