For Sun, you always need the definite article when referring to the star itself. The only time you don't need it is when you're referring to the Sun's light/heat output...
"I like sun" is just about valid, but sun there just functions as shorthand for sunshine. Certainly that's what it means in the more common form "I like the sun" (note lack of capitalisation).
For Moon I can't come up with any context where you don't need the article...
"We put a man on the Moon", but you couldn't do anything on Moon.
Earth can take it or leave it (unlike world, which always needs the article)...
"The Earth is flat".
"Climate change threatens the Earth"
"The astronauts returned to Earth".
"It's like nothing on earth".
"Where on earth have you been?" (contrast with "What in the world was that?")
When the Earth is spoken of as a physical body, occupying space-time, it's normally preceded by the article, and often capitalised. As are Sun and Moon, but there's no universality about either convention, nor is capitalisation necessarily governed by whether the article is present or not. I've capitalised every usage after the article (as do most people), but there are exceptions.
When Earth is used more "metaphorically" to mean our whole environment (really, just the thin skin of biosphere on the surface of the planetary body, where nearly all things that concern us take place) it's more normal to omit the article, and I wouldn't normally capitalise either.
This text has a very annoying way of talking down to children by using absurdly short sentences. It also has one blatant astronomical error ("The moon takes 28 days to go round the Earth."). But I do not think it contains any real grammatical errors, just infelicities.
Best Answer
According to Garner's Modern American Usage, when referring to the planet we live on, when used with the definite article, it is "the earth", lower case. However, when it is used as a name for the planet without an article, like "Mars is smaller than Earth", you capitalize it. It says sun and moon are treated the same way.