JOHN BOLTON WEIGHS INLES LUBIN AT Business Insider gives reasons that make sense.
1) North Korea was emboldened after sinking a South Korean warship, The Cheonan, last May. Every country short of China blamed this attack on North Korea which got off Scot-free. With no consequences and no censure, this member of the Axis of Evil had no reason, like a spoiled and disobedient child, not to test the limits again.
2) This is another ploy---a bark louder than a bite---to rattle the international community into believing it has the capability of processing and enriching uranium when it really doesn't.3)
3) The attack seems to be anger and a temper tantrum seems over a military drill by South Korea it said was simulating an invasion of the North. The military drill, called Safeguarding The Nation, is a annual exercise involving 70,000 troops including some American forces.
4) Father to son regime change involving an internal power struggle as Kim Jong un replaces father Kim Jong il. Geopolitical analysts have warned of an internal power struggle that may result.
Anyway you slice it, North Korea, like Cuba and Venezuela is a desperate and deeply poverty stricken country which will stop at nothing to get the world's attention and respect.