The explosion may or may not have been some sort of accident. It very well could be just another form of conventional explosives testing. If not actual weapons testing, it may be some for of bunker testing if NoKo is figuring on entering the nuclear age and performing tests. If they are doing tests, then they will want monitoring bunkers just as the US did in the 40s-70s. A conventional blast may have been performed to test the mechanical percussive effects of such power on various structures. Similarly, structural testing could have been involved with the idea that it isn't for their own testing, but for withstanding possible foreign attacks. The various Gulf War actions showed just how unprotected key centers can be even though they seemed safe or in hardened bunkers. Such key centers including com centers, military control centers, airfields, etc.
There are a variety of reasons for larger scale conventional explosives testing. The US and some other countries may not engage in them so much as we used to do on a large scale as we have already done quite a bit in the past. NoKo was involved in civil unrest, war, and then post war issues while the US was doing decades of such work.
Had the explosion been nuclear, it would have showed up in atmospheric samples all over the world by now and would be no secret.