When will the earth explode?

The Earth will not explode. In about 5 billion years time, the Sun will have burnt all of it's hydrogen and will expand into a Red Giant. It's outer envelope will extend to the orbit of Venus, maybe further. Earth will not exist as we know it, but the planet will still exist. It will not explode. It's outer layers may melt and be vaporised, but the actual planet will still exist. Life will have died out millions of years before but the planet will still exist, even after the Sun has shed it's outer layers and become a white dwarf.

Over time, the Suns remnant will cool and the Earth will become nothing more than a very cold rocky planet orbiting a cold stellar remnant.