I would suggest two possibilities, with little additional evidence other than what is described above, except that which anyone may obtain anecdotally and/or through direct personal observation, as I have.
First, the longer-shot answer, is that I see a recurring theme of bankruptcy, particularly in the older sources. Might it be that, as the term "leg" is used to describe different stages of trades in finance, the word might first have been used to describe different tranches of loans? A last leg, then, might be like a 2nd,3rd or even later mortgage on a business or farm lands? Or, if one were paying an arm and a leg on interest, or selling off assets to pay one's debts, then it would be a very bad thing to be down to one's last legs (having sold off the arms already). I would suggest focusing research into the use of the term "legs" in conjunction with loans/lending/banking in the 1600s, and see what comes up.
The more likely answer, though, seems the simpler and far more ancient. The millipede answer may be the closest to the truth stated thus far. even if it is somewhat exaggerated, intentionally comical and not fully accurate, considering the organism's capability for regeneration. I would argue that the phrase actually refers to a typical 6-legged insect or 8-legged arachnid. I've crushed more than a few in my day, in my rural youth and military young-adulthood (I likely experienced the need to do battle with many-legged opponents almost as often as the average person living in the 1600s and prior would have, unlike many modern urbanites and academics who may be less familiar with the pathetic visage portrayed by a once-6-legged creature that has been reduced to 2 or 3). Indeed, the most common outcome when stepping on or swatting a many-legged pest, short of instant death, is a half-dead, still moving, mangled bug, which is almost always missing several of its legs. The same is true of an insect or spider that narrowly escapes attack by a predator or a competing species. Therefore, I suspect the phrase is literal, and does refer to a serial numbers of legs. The idiom makes far more sense if the original subject of the metaphor starts out with 6-8 legs, rather than 2.