The gravity of the sun pulls its mass inward. There is a lot of pressure on the Sun. The pressure forces atoms of hydrogen to fuse together in nuclear reactions. The energy from the reactions gives off different kinds of light. The light travels to the Earth. 
How is sunlight created?