North Korea attempted its first nuclear weapons test in October 2006, a test which most experts say was not altogether successful. A second, apparently successful test, was conducted in May 2009 in the wake of a similar period of activity around Yongbyon.
The military need for a third test after the second test was by all indications a success is questionable, but North Korea’s policies don’t always serve an obvious purpose and in many ways publicly “continuing” the program is probably more a diplomatic question than a technical one.
North Korea had withdrawn from the international peace talks shortly before the May 2009 test, and the test was seen primarily as spite against the US, followed with a missile test in the general direction of Hawaii (which sparked a flurry of scare stories). With the diplomatic situation getting worse and questions about North Korea’s internal stability forever being raised, its government may feel the need to launch another test or some other dramatic gesture as a show of strength.