More and more, it seems that the existence and persistence of life on Earth is the result of sheer luck. According to a new analysis of the history of the Milky Way, the best time and place for the emergence of life isn't here, or now, but over 6 billion years ago on the galaxy's outskirts.

That specific location in space and time would have afforded a habitable world the best protection against the gamma-ray bursts and supernovae that blasted space with deadly radiation.

As of about 4 billion years ago, the central regions of the galaxy (which include the Solar System) became safer than the outskirts - safe enough for life to emerge, if not quite as safe as the outskirts had been.

"Our work shows that, until 6 billion years ago, excluding the peripheral regions of the Milky Way, which had relatively few planets, due to high star formation and low metallicity, planets were subject to many explosive events able to trigger a mass extinction," explained astronomer Riccardo Spinelli of the University of Insubria and the National Institute for Astrophysics (INAF) in Italy.

Cosmic explosions are no joke. Incredibly energetic events such as gamma-ray bursts and supernovae send cosmic radiation flying through space; so intense is the output that it can be deadly to life.

Earth hasn't been immune, either. Mass extinctions throughout our history have been linked to supernovae, including the end-Pliocene extinction 2.6 million years ago and the Late Devonian extinction 359 million years ago. Gamma-ray bursts, which are far more rare but much more powerful than supernovae, would be likewise devastating.

Both events are linked to the life cycles of stars. Supernovae occur when a massive star reaches the end of its main sequence lifespan, or a white dwarf accreting material becomes unstable, reignites and kicks over into runaway fusion. Both scenarios result in a massive explosion of stellar material into space.

Gamma-ray bursts are thought to be spewed out from stars collapsing into neutron stars or black holes, and we know they can occur when neutron stars merge. We've never actually seen one in the Milky Way; the ones we detect come from other galaxies millions of light-years away - the most energetic electromagnetic events in the Universe.

Scientists believe that a gamma-ray burst 450 million years ago could have triggered the Ordovician mass extinction, before the age of the dinosaurs.

"Supernovae are more frequent in star-forming regions, where massive stars are formed," said astronomer Giancarlo Ghirlanda of the INAF.

"Gamma-ray bursts, on the other hand, prefer star-forming regions that are still poorly engulfed by heavy elements. In these regions, massive stars that are formed by metal-poor gas lose less mass during their life due to stellar winds. Therefore, these stars are able to keep themselves in rapid rotation, a necessary condition to be able to launch, once a black hole has formed, a powerful jet."

To figure out the safest places for life, the research team carefully modelled the evolutionary history of the Milky Way, paying attention to the emergence of regions most likely to harbour supernova or gamma-ray burst activity.

Their model predicted that the inner regions of the galaxy would have formed more quickly than the outskirts; therefore, the inner Milky Way would have been much more active in both star formation and cosmic explosions. Over time, the star formation rate in the inner region slowed, but increased in the outer regions of the galaxy.

When the Universe was young, it was mainly filled with hydrogen and helium - the gases the first stars were made of. Heavier elements were built from the stellar fusion of nuclei; and heavier elements still from supernova explosions.

As stars lived and died, the central region of the Milky Way became richer in heavier elements and metals.

In turn, this would have reduced the frequency of gamma-ray bursts, making the central region - between about 6,500 and 26,000 light-years from the galactic centre - safer than it had been.

"Excluding the very central regions, less than 6,500 light-years from the galactic centre, where supernova explosions are more frequent, our study suggests that evolutionary pressure in each epoch is determined by GRBs mainly," Spinelli said.

"Although they are much rarer events than supernovae, GRBs are able to cause a mass extinction from larger distances: being the most energetic events, they are the bazookas with the longest range."

Although the Milky Ways' outskirts were safer once than the middle regions are now, the news does get better - for us, anyway. According to the team's analysis, in the last 500 million years the Milky Way's outskirts would likely have been sterilised by two to five long gamma-ray bursts. Our Solar System's location, on the other hand, became safer than it has ever been.

But even the relative danger and repeated exposure to cosmic explosions could have been fortuitous for us.

"We note that the very existence of life on planet Earth today demonstrates that mass extinctions do not necessarily preclude the possibility of complex life development," the researchers wrote in their paper.

"On the contrary, mass extinctions occurring at the right pace could have played a pivotal role in the evolution of complex life forms on our home planet."

So maybe "safety" needs to be taken with a grain of salt.

The research has been published in Astronomy & Astrophysics.