People have wrestled with the mystery of why the universe exists for thousands of years. Pretty much every ancient culture came up with its own creation story - most of them leaving the matter in the hands of the gods - and philosophers have written reams on the subject. But science has had little to say about this ultimate question.

However, in recent years a few physicists and cosmologists have started to tackle it. They point out that we now have an understanding of the history of the universe, and of the physical laws that describe how it works. That information, they say, should give us a clue about how and why the cosmos exists.

Their admittedly controversial answer is that the entire universe, from the fireball of the Big Bang to the star-studded cosmos we now inhabit, popped into existence from nothing at all. It had to happen, they say, because "nothing" is inherently unstable.

This idea may sound bizarre, or just another fanciful creation story. But the physicists argue that it follows naturally from science's two most powerful and successful theories: quantum mechanics and general relativity.

Here, then, is how everything could have come from nothing.

Particles from empty space

First we have to take a look at the realm of quantum mechanics. This is the branch of physics that deals with very small things: atoms and even tinier particles. It is an immensely successful theory, and it underpins most modern electronic gadgets.

Quantum mechanics tells us that there is no such thing as empty space. Even the most perfect vacuum is actually filled by a roiling cloud of particles and antiparticles, which flare into existence and almost instantaneously fade back into nothingness.

These so-called virtual particles don't last long enough to be observed directly, but we know they exist by their effects.

Space-time, from no space and no time

From tiny things like atoms, to really big things like galaxies. Our best theory for describing such large-scale structures is general relativity, Albert Einstein's crowning achievement, which sets out how space, time and gravity work.

Relativity is very different from quantum mechanics, and so far nobody has been able to combine the two seamlessly. However, some theorists have been able to bring the two theories to bear on particular problems by using carefully chosen approximations. For instance, this approach was used by Stephen Hawking at the University of Cambridge to describe black holes.

In quantum physics, if something is not forbidden, it necessarily happens

One thing they have found is that, when quantum theory is applied to space at the smallest possible scale, space itself becomes unstable. Rather than remaining perfectly smooth and continuous, space and time destabilize, churning and frothing into a foam of space-time bubbles.

In other words, little bubbles of space and time can form spontaneously. "If space and time are quantized, they can fluctuate," says Lawrence Krauss at Arizona State University in Tempe. "So you can create virtual space-times just as you can create virtual particles."

What's more, if it's possible for these bubbles to form, you can guarantee that they will. "In quantum physics, if something is not forbidden, it necessarily happens with some non-zero probability," says Alexander Vilenkin of Tufts University in Boston, Massachusetts.

A universe from a bubble

So it's not just particles and antiparticles that can snap in and out of nothingness: bubbles of space-time can do the same. Still, it seems like a big leap from an infinitesimal space-time bubble to a massive universe that hosts 100 billion galaxies. Surely, even if a bubble formed, it would be doomed to disappear again in the blink of an eye?

If all the galaxies are flying apart, they must once have been close together

Actually, it is possible for the bubble to survive. But for that we need another trick: cosmic inflation.

Most physicists now think that the universe began with the Big Bang. At first all the matter and energy in the universe was crammed together in one unimaginably small dot, and this exploded. This follows from the discovery, in the early 20th century, that the universe is expanding. If all the galaxies are flying apart, they must once have been close together.

Inflation theory proposes that in the immediate aftermath of the Big Bang, the universe expanded much faster than it did later. This seemingly outlandish notion was put forward in the 1980s by Alan Guth at the Massachusetts Institute of Technology, and refined by Andrei Linde, now at Stanford University.

As weird as it seems, inflation fits the facts

The idea is that, a fraction of a second after the Big Bang, the quantum-sized bubble of space expanded stupendously fast. In an incredibly brief moment, it went from being smaller than the nucleus of an atom to the size of a grain of sand. When the expansion finally slowed, the force field that had powered it was transformed into the matter and energy that fill the universe today. Guth calls inflation "the ultimate free lunch".

As weird as it seems, inflation fits the facts rather well. In particular, it neatly explains why the cosmic microwave background, the faint remnant of radiation left over from the Big Bang, is almost perfectly uniform across the sky. If the universe had not expanded so rapidly, we would expect the radiation to be patchier than it is.

The universe is flat and why that's important

Inflation also gave cosmologists the measuring tool they needed to determine the underlying geometry of the universe. It turns out this is also crucial for understanding how the cosmos came from nothing.

Einstein's theory of general relativity tells us that the space-time we live in could take three different forms. It could be as flat as a table top. It could curve back on itself like the surface of a sphere, in which case if you travel far enough in the same direction you would end up back where you started. Alternatively, space-time could curve outward like a saddle. So which is it?

There is a way to tell. You might remember from maths class that the three angles of a triangle add up to exactly 180 degrees. Actually your teachers left out a crucial point: this is only true on a flat surface. If you draw a triangle on the surface of a balloon, its three angles will add up to more than 180 degrees. Alternatively, if you draw a triangle on a surface that curves outward like a saddle, its angles will add up to less than 180 degrees.

So to find out if the universe is flat, we need to measure the angles of a really big triangle. That's where inflation comes in. It determined the average size of the warmer and cooler patches in the cosmic microwave background. Those patches were measured in 2003, and that gave astronomers a selection of triangles. As a result, we know that on the largest observable scale our universe is flat.

It turns out that a flat universe is crucial. That's because only a flat universe is likely to have come from nothing.

Everything that exists, from stars and galaxies to the light we see them by, must have sprung from somewhere. We already know that particles spring into existence at the quantum level, so we might expect the universe to contain a few odds and ends. But it takes a huge amount of energy to make all those stars and planets.

The energy of matter is exactly balanced by the energy of the gravity the mass creates

Where did the universe get all this energy? Bizarrely, it may not have had to get any. That's because every object in the universe creates gravity, pulling other objects toward it. This balances the energy needed to create the matter in the first place.

It's a bit like an old-fashioned measuring scale. You can put a heavy weight on one side, so long as it is balanced by an equal weight on the other. In the case of the universe, the matter goes on one side of the scale, and has to be balanced by gravity.

Physicists have calculated that in a flat universe the energy of matter is exactly balanced by the energy of the gravity the mass creates. But this is only true in a flat universe. If the universe had been curved, the two sums would not cancel out.

Universe or multiverse?

At this point, making a universe looks almost easy. Quantum mechanics tells us that "nothing" is inherently unstable, so the initial leap from nothing to something may have been inevitable. Then the resulting tiny bubble of space-time could have burgeoned into a massive, busy universe, thanks to inflation. As Krauss puts it, "The laws of physics as we understand them make it eminently plausible that our universe arose from nothing - no space, no time, no particles, nothing that we now know of."

So why did it only happen once? If one space-time bubble popped into existence and inflated to form our universe, what kept other bubbles from doing the same?

There could be a mind-boggling smorgasbord of universes

Linde offers a simple but mind-bending answer. He thinks universes have always been springing into existence, and that this process will continue forever.

When a new universe stops inflating, says Linde, it is still surrounded by space that is continuing to inflate. That inflating space can spawn more universes, with yet more inflating space around them. So once inflation starts it should make an endless cascade of universes, which Linde calls eternal inflation. Our universe may be just one grain of sand on an endless beach.

Those universes might be profoundly different to ours. The universe next door might have five dimensions of space rather than the three – length, breadth and height – that ours does. Gravity might be ten times stronger or a thousand times weaker, or not exist at all. Matter might be built out of utterly different particles.

So there could be a mind-boggling smorgasbord of universes. Linde says eternal inflation is not just the ultimate free lunch: it is the only one at which all possible dishes are available.

As yet we don't have hard evidence that other universes exist. But either way, these ideas give a whole new meaning to the phrase "Thanks for nothing".