A common plot point in science fiction stories is that the human race is on the verge of being wiped out. However really threatening the human race with extinction is much harder then you would think.
When I say humanity being wiped out I mean that the human race would not last another generation, not just that a lot of people died. Wiping out 99.9999% of humanity would not by itself wipe out our viability as a species.
Depending on who you talk to you would only need between 15 (see the island of Tristan da Cuhna) and 200 people to start a large population. That is reproducing with no scientific help (stored eggs, sperm and DNA tests to help with incest).
Contrary to what zombie movies would have you believe diseases won’t do it. The problem is that the faster and more deadly a disease is the easier it is to contain and diagnose. The slower it is the more it is the more time you have to stop and cure it.
Even if you have a disease that hits the happy (or unhappy really) middle there are too many places it would not get to, outposts that are very rarely visited. The arctic or antarctic, ships at sea ect.
Even if you had aliens engineer the perfect disease and drop it over all major cities and towns at once it would not be enough if they wanted to kill us all off, way too many people would be missed.
If they somehow saturated the earth’s atmosphere with it there are people who would live (submerged submarines for example) even with no warning. After that they would have to do it the hard way, use boots on the ground (or robots or whatever) to dig out the humans that were left.
Nuclear war is used sometimes too, although its not the goto it was during the cold war. However it would leave huge swaths of the world unaffected. And remember that after about 110 years the irradiated soil radiation level would be back down to background levels. That is if you don’t replace it or do anything other then wait. Short of placing nuke’s in a grid pattern over the entire earth they would not be enough.
If you really wanted to have humanity being wiped out on the table the threat would need to drastically effect the earth’s biosphere. This is the only thing that could kill everyone everywhere on earth.
The biosphere change would have to huge. If there was any possibility of being able to survive in a dome someone would be able to throw it together.
There are only a few things that come to mind, first would be a comet or asteroid. Contrary to what Hollywood would have you think short of a best case scenario we would probably all die if we were hit if they were big enough.
Worse case is a large comet because we could have as little as a week warning. Comets only gain tails and become easy to find when they get past Jupiter’s orbit. Given they have long orbits (thousands of years for most) we will probably not know about the one that kills us before it’s tail lights up. They move fast enough that we could have as little as one week from seeing it to dying. There would be nothing whatsoever we could do in that situation.
Best case is we its a solid (rather then a collection of small rocks and gravel) asteroid and we have several orbits as it slowly gets closer to hitting us. If that was the case over several years we could divert it at perigee or apogee with minimal effort.
You could also change the sun’s output. It would not take too much in either direction, although remember the supreme efforts that would be put to survival if that were to happen. Raising the average temperature by say 20 degrees would not be enough, or even close. The change would have to be enough that even with the collective efforts of mankind we could not survive.