What can cause a child to go from good eyesight to needing glasses?

Various. Genetics, growth, trauma, too much near work, etc.
Few different causes. There are a few main things that can cause a child to need glasses. Children should be examined when they are younger to establish a baseline measurement. With normal growth of the eye during childhood, a refractive error (such as nearsightedness) can develop. Also some children can develop strabismus, which is when the eyes don't align properly. Glasses can help these conditions.