Taken from songfacts.com:
This was written by two sisters from Kentucky, Mildred Hill and Patty Hill. They both taught nursery school or kindergarten. Patty invented the "Patty Hill blocks" used in schools nationwide, and served on the faculty of the Columbia University Teachers College for thirty years. Mildred, who was the older sister, studied music and became an expert on Negro spirituals. In 1893, while Mildred was teaching at the Louisville Experimental Kindergarten School where her sister served as principal, she came up with the melody to this song. Patty added some lyrics and it became a song called "Good Morning to All," which was a way for teachers to greet students. Here are the original lyrics:
Good morning to you
Good morning to you
Good morning, dear children
Good morning to all.
Later in 1893, the song was published in the songbook Song Stories For The Kindergarten, and other schools started singing it. After a while, it became more popular for kids to sing it to teachers, and the song became commonly known as "Good Morning To You," since the third line could be changed to fit the subject.
Here is some more interesting information about the song:
as named the highest-earning song of all time in the documentary The Richest Songs In The World, which aired on BBC Four on December 28, 2012. Runner-up was Irving Berlin's "White Christmas."
This was the first song to be performed in outer space. On March 8, 1969, the astronauts on Apollo IX sang it to celebrate the birthday of Christopher Kraft, who at that time was director of NASA space operations.