What would happen if a nuclear weapon were detonated on the Moon?
Short answer: Basically nothing, but don't try it anyway.
Long answer: If it's the Tsar Bomba, which is the largest nuclear weapon ever detonated, it will release 240 petajoules of energy (equivalent to 57 megatons of TNT). If you detonate it on the lit side of the moon during a full moon, your eye probably won't be able to register it. If you do it on the dark side during a new moon or crescent moon, your eye might be able to resolve a blip for a few seconds.
The fireball made by the Tsar Bomba was about 8 km, or 5 miles, in diameter. On the moon it might be substantially bigger due to the lack of the atmosphere. It will certainly make quite the crater, but if it's any smaller than about 100 miles across, you probably won't be able to resolve that crater with the naked eye. A telescope might make it possible though.
As for the moon's orbit? Don't worry too much about it. Orbits aren't as finicky as they show in the movies, with little pushes destabilizing entire systems. Orbits are rigid as steel, so the push the moon gets from the bomb will be nearly imperceptible.
Basically, the effect of the bomb on the earth and moon is almost nothing.
However, this is still a really bad idea. If you try to transport a bomb to the moon, and if the rocket carrying it blows up during the launch, you have done a lot of damage on earth. For one, you might obliterate your launch facility. That's bad. For another thing, if the rocket blows up while it's already pretty high up, you have a chance of causing an electromagnetic pulse, or EMP.
How do we know this? Because of course the US government did it in the 60s "just to see what would happen." A nuclear bomb was detonated 250 miles above the surface of the earth in a test called "Starfish Prime." It was a huge success, or terrifying success, depending on your definition of success.
Since they were out in the middle of the Pacific, the only nearby population center was Hawaii. The EMP went off the scales of the military's instruments, blew out streetlights, and knocked out telephone communication between the islands. Remember, this was the 60s; if they did this today hard drives and digital electronics for hundreds of miles are likely to be fried.
Basically, a big EMP is actually a really big threat to computers/the power grid- and it doesn't even have to be from the a nuke. If the sun spits out a big coronal mass ejection, and if that strikes the earth, it could very easily induce huge electric currents in power lines, damaging power distribution stations on the ends. That would be bad. Like, world endingly bad.
The U.S. Air Force actually considered detonating a nuclear device on the moon in the 1950s. Known as Project A119, the single explosion would have had little impact on the Moon.
(More reading at Newsweek)
I'm hardly qualified to get *too* scientific here but I guess I'd have to say "not much".
It's easy to lose sight of scale here. That thing in the sky that doesn't look like much, because it's about 240,000 miles away, is actually a giant ball of rock with a mass of 73,420,000,000,000,000,000 tonnes.
So without even attempting the calculations, on that scale, I'd say that the effect of such a bomb on the moon would be like attaching a firecracker to the side of your house. Locally there might be a bit of scorching on the paintwork and you might kick up a little dust, but you're not going to damage the walls, let alone move the house.
Nuclear weapons are bad news for us not because they threaten the cosmic balance of the Earth, but because we are vulnerable creatures. If the heat or the force of the blast doesn't kill you, the the radiation will. Everything that is around us is susceptible to destruction as a result of the energy that such a bomb releases.
But we are tiny tiny tiny (oh, and did I say tiny?) specks in this universe and nothing that is man-made can hope to compete with forces of nature, or the forces in our solar system and beyond.
I am not a physicist, nor do I play one in the media. That said...
You'd get a brief flash, barely visible from earth unless it was a) on our side, and b) in part of the Moon then in shadow. Only those then looking, would see it as it would not last very long. If you want an audience, hire a good PR firm to get the word out early.
Locally to the blast, you'd get something of a daisy cutter (GBU-43/B Massive Ordnance Air Blast ) (MOAB) effect melting the lunar Regolith close to your blast and blowing some of the un-melted dust away to a greater distance.
This is potentially "useful work" because we know that moon dust is very very very small, and a real PITA to deal with on just one EVA. If you are going to be going in and out every day for months and months, using a nuke to melt/dust-off the regolith in the area could even be cost-effective, not to mention a rare way to re-purpose old junk weapons.
Most modern thinking is that you probably want to put your lunar base inside a Lunar lava tube with a long walk-out (think covered Porch) to shed as much dust as possible before re-entering the hab. This gives you a lot of free protected space and some free cosmic radiation shielding.
Dusting the area around a future lunar base, whether it is inside a lava-tube or all on the surface, with a nuke is the sort of thing that an OCD engineer type would like. S/he might even get it funded. Radiation decay would be a fairly simple calculation, but a year or so, should manage most of it, and you can test your math with lunar roving 'bots or lunar satellites.
Modern dial-a-yield multi-stage nukes come in two flavors: Dirty and not-so-dirty. The term 'clean' is often used, but ah... call that a relative term. Most of the inventory is the latter, using lead reflectors in the secondary instead of uranium. Wikipedia's many articles on Nuclear weapon is a good afternoon's reading. But I digress. You'd probably want to dial the device to high yield and use a "clean" core.
You'd end up with a low-dust zone that could be an ideal spot for your home base... after a few years cooling.
There was actually a plan to Nuke the moon by the US during the cold war in order to show their power as a nuclear explosion on the moon could be seen by everyone on earth .
This plan was dropped as the moon was unexplored and they did not want to destroy it and the license on the moon if there was any .
Upper atmosphere nuclear test ban treaty also prevented them from nuking the moon .
It would be political impossible for Elon musk to Nuke the moon because of the nuclear ban treaty .
And the US is not dumb to give a nuclear warhead to a private company .
Even if he nuked the moon it would be of no use as moons gravity is not strong enough to have an atmosphere in the first place .
And also the radiation on the moon would go up and no human would be able to explore the moon without dieing due to radiation . Same logic applies for mars .
An alternative is for a space X to go to the asteroid belt and pick up an asteroid and change its orbit so that it crashes into mars .
The resulting energy by the formula ½mv² released by the asteroid is equal to that of a nuclear blast but without the radiation .
Over time and many asteroids later the temperature on mars will increase and mars will be terraformed .
Some asteroids may contain water due to which mars will have water and then soon life with human intervention .