The sun formed from a collection of gas and dust that pulled together by mass gravitation; the extreme pressure caused by this great mass produced a nuclear fission reaction that fueled the sun and continues to keeps it burning. The primary elements that make up the sun are hydrogen and helium. Scientists theorize that the shock wave from a large supernova drew together the dust particles that became the sun.
Originally, the sun was an enormous molecular cloud made up of dust particles. Approximately 4.57 billion years ago, this slowly rotating molecular cloud began to compress under its own gravity. The compression caused it to spin faster and faster, until the spinning flattened the matter into a huge disk. A gas sphere comprising most of the mass was at the center of this disk.
More and more mass began to accumulate at the center of the disk, causing it to compress. This led to dramatically increased pressure, a pressure so strong that it provoked a nuclear reaction. Atomic fusion occurred at the center of the sphere, forming helium and releasing incredible amounts of energy. Thus, the star known as the sun was formed.
It took about 10 million years after its birth for the sun to turn into the main sequence type star that it is in modern times. According to calculations, it will shine for another 3 to 5 billion years.