Someone who is virtuous in a coy, smug or sentimental manner.
This phrase derives from the title of the nursery tale The History of Little Goody Two-Shoes, which was published in 1765. The authorship of this is disputed. Oliver Goldsmith is the name most commonly associated with it, although the evidence that claim is largely circumstantial and is based on the fact it is considered to be in Goldsmith's style and that he had previously undertaken the ghost-writing of somewhat similar stories for cash rather than as a named author. 'Anonymous' is probably the wisest choice when naming an author of this book.
The story itself is a re-telling of the Cinderella story, which itself is an example of the Christian teaching that diligence reaps its reward in Heaven - what later came to be called 'jam tomorrow'.
'Goody Two-Shoes' is the name given to a poor orphan - Margery Meanwell. She is so poor as to possess only one shoe and is so delighted when given a pair of shoes by a rich gentleman that she keeps repeating that she has 'two shoes':
"She ran out to Mrs. Smith as soon as they were put on, and stroking down her ragged Apron thus, cried out, 'Two Shoes, Mame, see two Shoes'. And so she behaved to all the People she met, and by that Means obtained the Name of 'Goody Two-Shoes,
By virtue of hard work she makes good and marries a wealthy widower - thus mimicking the Cinderella theme of virtue being finally rewarded.
People who were considered self-righteously or piously virtuous began to be called 'goody-goodies' from around the turn of the 20th century. There are a few examples of people's behaviour being called 'goody-goody' from 1896 onwards. The first example that I've found of someone being described as 'a goody-goody' comes from 1911 - in the Wisconsin newspaper The Racine Daily Journal, July 1911, in a piece with the heading A Goody-Goody:
"Philadelphia Press: Senator Lorimer according to his friends, is such a paragon of innocence and true goodness that what seems to be needed is a place where he can retire, safe from the world - and the world safe from him."
The childish exclamation of delight 'goody, goody' may derive from Goody Two-Shoes, although it could just as easily just be a form of 'oh good'.
The children's phrases 'goody gumdrops' and 'goody, goody gumdrops' began life in the mid 20th century. The expression is found in the Harold Teen cartoon strip by the American cartoonist Carl Ed in 1936. 'Goody gumdrops' is recorded, as a commonplace British children's expression, by the Opies - Iona and Peter, in The lore and language of schoolchildren, 1959:
" Cries of jubilation include: Wow! Whacko! Goody gumdrops! Lovely grub! and By gog jolly custard!"