The sun is a very large thermonuclear furnace where hydrogen is converted into helium at temperatures in the millions of degrees. It formed during the early period of the solar system, as gas and dust fell toward a common center of gravity and compressed until it was hot enough to sustain fusion.
The hydrogen in the sun is in motion. The higher the temperature of the stellar plasma, the harder the atoms of hydrogen collide with each other. At the very high temperature of the sun's core, hydrogen collisions are too energetic for the mutual repulsion between the atoms' electron shells to resist each other, and they instead fuse into new atoms of helium. A single atom of helium has slightly less mass than two atoms of hydrogen. The difference in mass represents the matter that has been converted to energy by the fusion, a process described by Einstein's famous equation E = mc^2.
The energy liberated in the core of the sun is mostly in the form of neutrinos and gamma rays. Neutrinos pass out of the sun and into space at the speed of light, barely interacting with matter as they go. The gamma rays, however, pass through the layers of the sun and are absorbed and re-emitted millions of times before finally being released as light from the sun's photosphere.