The sun formed 4.6 billion years ago from a dust cloud that collapsed under gravity. It is made primarily of hydrogen and helium and is about 93 million miles from Earth. As the sun exhausts its hydrogen fuel over billions of years, it will expand into a red giant and later shrink into a white dwarf. The moon's phases are caused by its orbit around Earth as the sun illuminates different parts of the moon each month from our perspective on Earth. As the moon revolves around us, we see more or less of the side illuminated by the sun, appearing as a waxing and waning crescent, half moon, and full moon over the course of about 29.5 days.