We have many years worth of data from underground nuclear testing. You need only 1000 feet of depth for a 1/2 kiloton explosion to be "contained", and they have 12,000 feet of rock between the ocean floor and the oil. I think they have a significant safety margin, but they would probably detonate it 6000' deep to be on the safe side. it's much safer cleaner and cheaper than what's happening now.
You have 5000 feet of water and then 18000 feet of pipe. I think the well is about 12 inches and narrows down to 6 inches at the bottom.
Do we have a nuke that small? How do we push it down the pipe against the pressure of the oil?
Are you gonna call Bruce Willis to stay behind and push the button? How else will you hold it in place against the thousands of pounds of pressure long enough to trigger it?