Like any star, the Sun is locked in a long-term game of “tug-of-war” between two forces. The Sun has a lot of mass, and gravity pulls things with mass together. So gravity is trying to make the Sun collapse. In the centre of the Sun, nuclear fusion is making helium out of hydrogen, creating light and heat (and neutrinos) which radiate outwards. The size of the Sun — and any star — is the balancing point between this pull inwards and this push outwards.
The Sun has been burning hydrogen into helium for about five billion years. It has enough hydrogen inside to keep this up for about another four billion years. When it runs out, gravity will “win” and the Sun will start to collapse.
As the Sun collapses, it will heat up. Things get hot when they get compressed. When it gets hot enough, the helium will “ignite” and a new nuclear fusion process will start, buring helium into things like carbon and oxygen.
(Actually, you might be interested in knowing that all the elements heavier than hydrogen and helium and maybe a bit of lithium were produced in the heart of stars!)
When this helium burning happens, the size of the Sun will change, as there will be a new balance between the outward radiation pressure and the gravitational pull. At this point, the Sun will be a type of star known as a “red giant”. It will be so big that it will extend out past the Earth, consuming our planet, as well as Venus and Mercury.
For a really massive star, it eventally explodes in a supernova when it runs out of all possible fuel to burn. That’s pretty awesome! For a medium sized star, like our Sun, it wil simply cool off when there is nothing left to burn, and it will become something called a “white dwarf” star.
The sun is made of stuff called atoms… These atoms are being smashed in to each other because of gravity. This causes some of them to stick together to make new, bigger atoms. This sticking is called fusion. The larger the atoms, the harder it is for them to fuse together. When the sun runs out of small atoms, it will start to die.
The sun produces all its light and heat by fusing hydrogen atoms together to form helium, which releases lots of energy. In about 1.2 billion years, the hydrogen fuel will run out and the sun will start to die. The internal core of the sun will collapse, and heat up, until it is hot enough to fuse helium into carbon.
Eventually the pressure will increase and the sun will expand to almost in size and become a red giant. It will stay like this for around 700 million years then grow larger again while becoming dimmer. After this the outer layer of the sun will blow off and the sun will keep on expanding until it’s over 166x the size it is today. Mercury and Venus will be engulfed and the Earth’s surface will melt.
The sun will get a little bigger until all the helium and hydrogen is gone and then the surface size will increase and decrease rapidly. Each expansion throws off more material and the sun loses more and more mass. Eventually, all that remains is a very hot core which slowly cools down until no heat is left. Then all that is left is a shell.