Writing "G_d" is a practice based on the 3rd commandment ("You shall not take the name of YHWH [probably to be pronounced 'Yahweh,' traditionally ' translated as 'the LORD'] your God in vain.") But why and how did this PARTICULAR way of trying to keep the commandment come about?
(In its original context the command likely had, first of all, to not dishonoring God by such behavior as lightly taking OATHS in his name and not keeping them, by extension to speaking or acting "in his name," whether claiming to speak for him, as his representative, or by claiming to follow him, but living in a way that brings dishonor to him.)
But one significant expression of attempting to guard and honor the sanctity of the divine name (sometimes called the "tetragrammaton" after its four letters: Y-H-W-H) that we find many expressions of after the Babylonian Exile (6th century BC) is in special treatment of the spoken and written name(s) of God, beginning with "YHWH", and at times extending to other names and titles.
We see it in how the name was written in the scrolls of the Hebrew Bible, as well as in their early Greek translations. After the Babylonian Exile the Jews adopted the Aramaic letter forms in place of their own earlier forms. But among the Dead Sea Scrolls we find Scriptures written in the Aramaic letters, but with the divine name (which in English may be rendered YHWH) written in the older "paleo-Hebrew" script. Many early Greek translations (some as late as the 4th century AD) have the divine name written either in the Hebrew letters, or using Greek letters that LOOK like the Hebrew word. (If read as Greek one would say "Pipi", but there is no evidence such a pronunciation was ever intended.)
Another way of honoring the name YHWH that grew up at the same time was to avoid SAYING the name by substituting another Hebrew word (for Greek speakers it might be the Greek equivalent). For example, we find references to "the Name". This was at times extended to other divine names. So, for instance, in place of "God" one might say "heaven". We find some reflections of this in the NT, esp. in the gospel of Matthew, who (writing chiefly to JEWISH Christians) ordinarily speaks of the "kingdom of heaven" where other gospels use "kingdom of God".
The most important substitute was that of the word for "Lord" in place of the name YHWH. The Hebrew word was "ADONAI", Greek speakers used their equivalent, "KYRIOS". In fact, the NT throughout uses "Lord" (kyrios) when quoting OT passages that use the divine name YHWH. (This is important in connection with the claim of Christians that Jesus is divine -- calling him "Lord" was not just honoring him as "Master" but applying the divine name to him.) This practice has continued to be followed in most Scripture translations from the Hebrew, including the use of "the LORD" in most English translations. (Usually small caps are used to indicate that the original used "YHWH" not "Adonay".)
Evidence for the Jewish practice is found in the customs of the Masoretes -- Hebrew scribes who carefully preserved the Hebrew text of Scripture, and added a system of markings, including accents and vowel-markings, to preserve the traditional understanding of the text. In the Masoretic manuscripts of the Hebrew Bible the name YHWH is marked with an unusual set of vowels, which if we tried to pronounce them would yield "Yehowah' [in later English, Jehovah"]. But that is not what they intended. Rather they marked the word with the vowels from "Adonay" to indicate that THIS was the word to be spoken when you came to the divine name.