The book of Samuel (originally 1-2 Samuel formed a single book) had a very complex literary history and the Goliath problem is just one facet of this history. The MT version that is the basis of modern translations is but one edition of this book; the LXX represents another ancient edition that was much shorter, and the Dead Sea Scrolls represent several other editions, some closer to the LXX and some closer to the MT. When the many versions are compared with each other, it is apparent that the book was reworked several times in antiquity.
It is generally accepted that the story of David and Goliath in 1 Samuel 17 MT is a relatively late reworking of an earlier story of a confrontation between David and an originally unnamed Philistine. The oldest recension of the LXX omits 17:12-31, 17:55-18:5, 18:17-19, and this material has a different literary style than the other verses and introduces David as a new figure entirely (cf. v. 12-13 especially) -- suggesting that the interpolated material came from an originally independent story about David (cf. also the doublet between v. 4-9 and v. 23). In this material, the opponent is simply known as "the Philistine" and only in v. 23 is he identified with Goliath of Gath in a gloss that rudely interrupts the sentence: "While he was talking to them, the warrior (His name was Goliath, the Philistine from Gath) came up from the Philistine ranks and made his usual speech, and David heard it". The more original form of the story in 1 Samuel 17:1-11, 32-54 also refers to the opponent only as "the Philistine" except for another awkward (and extravagent) gloss in v. 4-7 which separates the warrior's "stepping out from the ranks" in v. 4 from his "taking his stand" in v. 8:
Probable original version: "One of their warriors stepped out from the Philistine ranks and he took his stand in front of the ranks of Israel" (v. 4a, 8a).
Interpolated version: "One of their warriors stepped out from the Philistine ranks (His name was Goliath from Gath, he was 4 cubits and one span tall. On his head was a bronze helmet and he wore a breastplate of scale-armor; the breastplate weighed five thousand shekels of bronze. He had bronze greaves on his legs and a bronze javelin across his shoulders. The shaft of his spear was like a weaver's beam, and the head of his spear weighed six hundred shekels of iron. A shield-bearer walked in front of him) and he took his stand in front of the ranks of Israel" (v. 4-8a)
This gloss predates the interpolation of v. 21-31, 55ff, as it is found in both the MT and in the LXX, although the warrior's height has been reworked in the various editions, from 4 cubits in 4QSam a and the original LXX used by Josephus, to 5 cubits in the later text of the LXX, to 6 cubits in the MT. In other words, the oldest form of the story consisted of 17:1-4a, 8-11, 32-54 and then the gloss in v. 4b-7 was added (which identified the anonymous Philistine warrior with the famous Goliath), and then in a version that MT later represents, material from an originally independent version of the same story (v. 12-31, 55ff) were added to the text of 1 Samuel 17.
The writer who added the gloss in v. 4b-7 would have then took the name "Goliath" from the story in 2 Samuel 21:19 which says that Goliath was slain by "Elhanan, the son of Jair, the Bethlehemite". The extravagent description of Goliath's armor would then have been inspired by such descriptions as those in 2 Samuel 21:15, which describes another Philistine warrior's spear as "weighing three hundred shekels of bronze", and the description of Goliath's spear in v. 19 as having a "shaft like a weavers' beam". The fact that the hero is described as a "Bethlehemite" is also a point of contact with the Davidic story in 1 Samuel 17 as well. But the text of 2 Samuel 21:19 is problematic as well. The MT refers to Elhanan the son of Jair-Oregim whereas the parallel in 1 Chronicles 20:5 (the earliest witness to the text of 2 Samuel) refers to Elhanan the son of Jair. It is clear here that a copyist duplicated the word for "weavers" ('rgym) later in the same verse and misplaced it right after "Jair" (y`ry). Thus "Jair" and not "Jair-Oregim" (which is an odd name in Hebrew) is the name that occurs in 1 Chronicles and the older form of the LXX (which gives the name as Iare). It is in the later (hexaplaric) version of the LXX where the copyist error appears in the form Ariórgim (< Hebrew y`ry 'rgym), and since the late LXX text assimilates itself generally to the proto-MT text, this shows that the copyist error that produced the MT form of the text had already occurred by the third century AD.
Meanwhile, the version in 1 Chronicles has a copyist error of its own. In 2 Samuel 21:19, regardless of whether you consult the MT or LXX, Elhanan was a Bethlehemite (bytlchmy) who killed Goliath ('t-glyt), but 1 Chronicles 20:5 states that Elhanan killed Lahmi ('t-lchmy) who was the brother of Goliath ('chy glyt). The Chronicler here mistakes the word byt- (Beth-) as the inflection for direct object 't- and thus takes the remainder of the name bytlchmy (i.e. -lchmy) as a proper name, i.e. Lahmi. Meanwhile, the 't- inflection in the source was mistaken as the word for "brother" ('ch), making the Philistine the brother of Goliath, and not Goliath himself. Many of the Chronicler's departures from the Deuteronomistic History are ideological in nature, and there may be a motivation here to resolve the contradiction in 2 Samuel 21 by making Elhanan kill the brother of Goliath and not Goliath himself. Such a motivation presupposes that David had already been identified as Goliath's slayer. That would mean that the interpolation of v. 4b-7 in 1 Samuel 17 (which is found in all extant versions of the text) predates the composition of 1-2 Chronicles, and thus had already occurred before the fourth century BC. Or it could be that the interpolator of 1 Samuel followed the Chronicler in allowing himself to identify the slayer of Goliath as someone other than Elhanan (who for the Chronicler was not the slayer of Goliath). It is noteworthy that the LXX version of 2 Samuel 21 (which should go back to the third or second century BC) had an underlying btylchmy in its Vorlage, as it designates Jair as ho Béthleemités "the Bethlehemite", and there is no evidence anywhere in the textual tradition of 2 Samuel itself along the lines of "Lahmi the brother of Goliath". So here is an example of a text paralleled in two works (1-2 Chronicles being literarily dependent on 1-2 Samuel) which is corrupted in both.