As you know, it gets hot outside if the sun is shining brightly on a summer day. The reason it warms up is because the earth is absorbing some of that solar energy. However, not all of the energy is absorbed.
Some energy is reflected back into space in the form of light.
This reflection allows the earth to be seen as a star from other parts of our solar system, just like we can see the moon and other planets. Energy also leaves the earth in other forms like heat, for example, which is called infrared light. If we have more energy leaving than arriving, the earth will cool down and we could have another ice age. If we have more energy arriving than leaving, we will have global warming. The reason the earth could retain more energy than it gives off has to do with the air around us and what it is made of.