Over the past decades, nuclear weapons have become one of the strongest weapons on earth. Every ally likes to have more of these in a good amount. The trials regarding these weapons happen on earth. What if we try the same on the moon? Would that be helpful? Let's figure it out.
Let us fill a space vehicle full of nuclear weapons worth megatonnes. The space vehicle reaches the orbit of the moon and then the surface. Boom! For the first few milliseconds, nothing happens outside our weapon. Nuclear fission takes place inside the weapon, heating it enormously and setting up a chain reaction. This happens exactly as it occurs in the core of all the stars. Our weapon now is the hottest thing in the entire universe. It is only after milliseconds from here that the entire universe can realize something is happening as the bomb dissolves on the surface of the moon. The explosion created on the moon is almost a million degrees Celsius that almost vaporizes the water molecules on the surface in no time. Astronauts or space explorers in the vicinity will be fried to death. The explosion bubble keeps growing in size. On earth, the atmosphere would compress the explosion creating a gravitational shock that would rupture everything in around a 50km radius. Since there's no atmosphere to control this on the moon, the explosion bubble creates enormous tremors on the moon that would be about 7 on the Richter scale on earth. Further, the explosion sets off micro meteors all over the moon and towards space. These micro meteors might get pulled towards the earth causing a hard time for the satellites and space explorers. Space explorers who may be away from these micro meteors, watching this event happening will be still in danger, as they'll be exposed to a high amount of radiation as there's no filtration of this UV light. Within the next few seconds, the explosion would vanish leaving one more crater in the moon's account. This can be seen from earth as a star that flickers, but only once. Does the orbit of the moon change? Well, this would be more like trying to move a wall by pushing it.
While the moon would not ask us why we nuked it, it would be a wrong choice to do so as the radiation so created will stay on the surface forever contaminating it. While it seems to be a viable option, building anything new on the surface and trying to explore the moon will not be safe anymore. The hope of making the moon habitable will be shattered along with a part of the moon.