As Jon Peterson explores in the seminal D&D history book Playing at the World, hitpoints were one of the major elements which separated the RPG from the tabletop wargame. Individual attributes were generally not a part of confrontations in wargames, they were zero sum. You won a battle or you lot a battle depending on the factors of the rules. When things became focused around individual characters, bouts were extended and therefore progress needed to be tracked in a fight
However, in the earliest wargames there was the concept of "points" as a measure of endurance for units, but it seems that a lot of people didn't really take these calculations to heart. In hobbyist wargaming of the 1950s, they were virtually phased out, but came back into play in naval settings. It didn't really make sense for a warship to be destroyed in one volley, so the idea of "damage" became quantified. D&D co-creator Dave Arneson in particular was a huge fan of naval wargames and he took the idea for characters having hit points from these ship games.
There are, of course, some fundamental differences between ships and player characters in the settings. Traditional wargames are usually based around encounters, not scenarios, so you would rarely have it so that a damaged player would be fighting against a fully prepared foe. It was also not common to repair a ship during battle in the naval games, whereas D&D has potions and healing spells. The nomenclature of "hit points" is also important. It represented the number of times the character was hit, not the severity of the damage itself. This is more of a conceptual change, but did influence some of the original D&D rules.
Of course a certain class of ship could also not "upgrade" how many hits it could take. Strength being embedded into a character may be the essence of what D&D is mechanically so it was an incredibly important break from the past. The attribute system for individuals was first articulated in Gygax's Chainmail rulebook, then expanded in Arneson's Blackmoor setting, and became codified in Dungeons and Dragons. The hit points system does predate role-playing games, but as far as we know does not predate war games.
Source:
Playing at the World by Jon Peterson pages 331-341 is the only source and is the deepest look at the topic, barre none. I don't always agree with Jon's summations but he always lays out his case with sources. It digs down to the bone of every topic in RPGs, hit points included.
The term does come from Dungeons & Dragons. It appears in the original "White Box" D&D, Volume 1: Men and Magic.
Attacking : roll 1d20 and add relevant modifiers (BHB, STR, DEX, range penalties, etc.). A total equal to or greater than the target’s Armor Class indicates a hit, and the appropriate damage die may be rolled and subtracted from the target’s current Hit Points.
Hit Points (capitalized!) never get defined directly. You learn what they are in reference to other rules for attacking and death, and the term is used in the character classes before you find out what it means. Old D&D manuals are like this. They're mostly reference materials for insiders who already kind of know what's going on. They try to initiate newbies, sometimes, but they don't seem to have a clear idea how to make their rules accessible to outsiders. This tone is how we end up with clunky verbiage like "hit points" and "hit dice" instead of something less jargon-y like "health".
The original D&D was an evolution of an earlier TSR publication, a set of rules for historical wargaming called Chainmail. Chainmail was a game about tens or hundreds of tiny mans shooting and stabbing each other, and tracking the precise injuries of each individual tiny man was more granularity than it wanted. Chainmail combat has you roll one die for many units at once, then you compare to the column for the target's armor on a chart (Gygax loved him some charts) to get a second derived number.
What does that second number mean? Chainmail doesn't directly tell you. But to a 70s wargamer who knew what they're looking for, that would be the number of casualties inflicted. I'm speculating a little bit here, but players would informally call the rolled number of casualties, "hits".
Chainmail sometimes refers to men taken out by hits as "kills", but within the scope of the game it doesn't really matter what happened to them as long as they're not fighting anymore. Are they actually dead or just too injured to fight? Did they desert after a close brush with death that made them decide they cared more about living than about who controlled Agincourt? For Chainmail it doesn't matter, what matters is your army is one tiny man smaller. There are some optional rules for taking prisoners, rolled after the battle (unless you're playing Swiss or Tartars, who don't take prisoners for reasons a real historian might be able to explain) but even there it isn't important which tiny man became a prisoner.
Chainmail's Fantasy Supplement had two evolutionary steps toward D&D: wargaming with elves and wizards and stuff, but also wargaming with hero units. The paragraph on hero units contains very clear references to Bard and Aragorn from Tolkein. There's a special rule for shooting dragons out of the air, and an attack bonus that "rangers" get - this is before the game even has character classes! So, no matter how much Gygax had to downplay it for legal reasons, they're clearly inspired by Tolkein named characters and we have an idea of how powerful and narratively important they're supposed to be.
It wouldn't do to have these guys die to random archery volleys. If the forces of Mordor roll a "hit" on Aragorn's unit and get to decide to kill Aragorn or a random Gondorian footman, Aragorn bites the anticlimactic dust every time. But at this point, "hits" are binary, any hit is as severe as any other. So Chainmail kluges it:
[Heroes] are the last figure in a unit that will be killed by regular missile fire of [sic] melee, but they may be attacked individually by enemy troops of like type (such as other Hero-types) or creatures shown on the Fantasy Combat Table. Heroes (and Anti-heroes) may act independent of their command in order to combat some other fantastic character. When meleed by regular troops, and combat takes place on the non-Fantasy Combat Tables, four simultaneous kills must be scored against Heroes (or Anti-heroes) to eliminate them. Otherwise there is no effect upon them.
So here we have the idea that bringing down a hero unit requires the cumulative effect of multiple hits (or "kills").
D&D seems to have decided that this wasn't enough for a game where everyone has one unit and every unit is a Hero. It needed to start grading the quality of hits to distinguish between killed and wounded, and if wounded how wounded. So they came up with a point system for rating the cumulative effect of each hit and how many a hero could withstand. And in keeping with early D&D's clunky, insider-reference-material writing style, it was just called "hit points".