The Sun does not run out of fuel as the Sun is powered by nuclear fusion and not burning like a normal fire.
The Sun is powered by nuclear fusion, which is a very ultra efficient process, where immense gravitational pressure crushes hydrogen atoms together to form helium.
And because of it's colossal mass and this efficiency, the Sun still has enough fuel to last around 5 billion more years.
To keep burning, the sun is fueled by hydrogen which squeezes and converts into helium through a processed called nuclear fusion.
The Sun is not literally burning like a campfire for example, as a normal fire requires oxygen.
And instead the Sun functions as a giant natural nuclear reactor.
The Sun is composed of around 73 percent hydrogen and 25 percent helium.
And deep in the Sun's core, under extreme gravitational pressure and temperatures, the hydrogen and the atoms fuse together to form helium.
And every single second, the Sun also fuses around 600 million tons of hydrogen into helium.
This process also converts a small fraction of that mass into pure, raw energy.
The Sun also has been fusing hydrogen for around 4.6 billion years and still has enough hydrogen remaining in it's core to fuel the process for around another 5 billion years.
The Sun could eventually stop burning, but it would take billions of years for that to occur.
Inertia and the conservation of angular momentum is also what keeps the planet Earth spinning as the earth does not need a constant energy source or engine to keep it turning.
The solar system formed over 4.5 billion years ago from a massive, swirling cloud of gas and dust collapsing under it's own gravity and as the cloud shrank, it spun faster, which is similar to that of how an ice skater pulls in their arms to spin faster.
The debris that clumped together to form Earth inherited the spinning motion and according to Newton's first law of motion, it states that an object that is in motion will stay in motion unless acted upon by an outside force.
And because space is also practically a vacuum with almost no air resistance or friction to slow it down, Earth continues to coast on this initial, ancient momentum.
The universe and earth and the planets began forming around 13.8 billion years ago.
Although the universe, earth and planets was not formed from literal nothing, but instead was formed from an absence of space and time.
And as space rapidly expanded and cooled, matter condensed.
Then gravity subsequently pulled the gas and dust together to form the stars, planets and the Earth we live on.
Around 13.8 billion years ago is when the universe started, where all matter, energy and space were compressed into an infinitely dense point.
Then the expansion occurred, a the universe was not an explosion in space, by instead an explosive expansion of space itself also known as the Big Bang.
And as the universe expanded and cooled, energy then converted into fundamental particles.
These particles then bonded to form the simplest elements, mostly hydrogen and helium.
The sun and the solar system began forming around 4.6 billion years ago.
The sun and solar system forming started with cloud collapse, where a massive, swirling cloud of interstellar gas and dust, which was triggered by the shockwave of a nearby exploding star, collapsed under it's own gravity.
And for the igniting of the sun, the vast majority of this material also condensed at the center and created immense pressure and heat, eventually lighting the sun.
And then finally the Earth formed around 4.5 billion years ago.
Earth forming around 4.5 billion years ago started with dust to planets, where leftover dust and debris swirling around the infant sun collided, stuck together and then gradually grew into larger bodies called planetesimals.
And for the formation of earth, these bodies collided and merged over millions of years to build the rocky, terrestrial planets.
And earth formed as a molten ball of rock and metal.
And as it cooled down, heavier elements like iron sank to the core, while lighter materials also rose to form the crust and mantle.
Earth and all the planets and even all life on earth including us humans has always fascinated me and it's really amazing and mind boggling to think about.
Even the fact that a man and a woman can have intercourse or sex and a new human can be made inside a woman's body as a result of sperm and eggs and the process that it goes through.