What is the origin of 'Gosh'?
Solution 1:
Etymonline has this on the word:
gosh 1757, altered pronunciation of God. Probably from by gosse (mid-16c.).
but offers no additional information on gosse other than as a German word for gutter under the entry for gut.
Wikitonary's listing for gosse also seems to hold no further clues.
Here's a clip of the earliest use in print from Barry's OED answer:
This is from a 1765 collection of Samuel Foote's plays. This play, The Author, was originally published in 1757. He uses the phrase once again later in the same play:
Edit:
Just figured out that the by gosse mentioned at Etymonline is from Ralph Roister Doister, a comic play by Nicholas Udall generally regarded as the first comedy to be written in the English language. It was published c. 1567. Here is a clip from the play reprinted in 1821:
Solution 2:
Gosh has no literal meaning. It's not supposed to.
It's a Euphemism, which means it's a word that is used instead of a taboo word (in this case, as you suggest, the taboo word is God).
This is word magic, and the usual magic principle that requires correct pronunciation to effect magical results applies. (For example, in the case of Sanskrit, correct pronunciation of the Vedas was believed to be necessary for the preservation of the Universe, leading directly to the invention and development of a scientific phonetics by Pāṇini)
Specifically, if you offend a Power by saying its name, or referring to something forbidden, you may be noticed and punished; so you avoid that by saying something similar enough to be recognized by us humans who are in on the joke, which the Power nevertheless might not notice. Gods, as Terry Pratchett points out, don't have to be very smart or observant, when they have humans to do it for them.
The Greeks, who invented the term euphemism (from eu- 'good' + phazein 'speak'), attempted to apply it to the gods themselves; notably the Furies, who caused bad things to happen, by renaming them the Eumenides, or 'Gracious Ones', as chronicled by Aeschylus.
English is full of euphemisms; similar monosyllabic phonological euphemisms include geez (for Jesus), (the) heck (for (the) hell), shoot (for shit), futz (for fuck), etc. There are many other kinds, and there is a very thorough and fascinating discussion of the topic on Wikipedia .
Solution 3:
The OED calls it a ‘mincing pronunciation of god’. The earliest citation is dated 1757.