He's deliberately trying to provoke the USA/world in the hope than they'll give him the excuse to blow somewhere up. This is a man living in an alternate reality who is quite beside himself with excitement at the thought of being able to play with his new "big world leader" toys.
It's hard to analyse North Korean motives because of that state's secrecy, but I don't think they're as far removed from reality as you'd assume. The target of their parades, tests and announcements/threats is probably split at least 50/50. Half to their own people over whom they want to project an image of state power, half to their neighboring states (SK, Japan, and China of late), whom they're very suspicious of.
There's also the point that attaining nuclear capacity has historically been the first step to wider recognition within the world community, that recognition being that once a state is armed with nukes, you have to treat it with far more caution/respect. Their logic is that they've developed nuclear weapons and so, due to their location (bordering two superpowers, one key American ally, and very close to another key American ally), they'll eventually receive a better deal. That could be an end of sanctions, increased trade, and so on. But they're definitely playing the long game and have been since the 80s in terms of nukes.
It's an anomalous state owing to its authoritarian nature and also the inability/unwillingness of other states to topple it. I seriously doubt any influential military figures within North Korea (including Kim) want a war of any sort. It's the only scenario in which they lose everything and gain nothing. The same is true of the US, though the US would lose far less (theoretically, if China and Russia were willing to acquiesce, or actively engage) as it can't be destroyed by NK, it would still put the world into a state of potential doomsday. The most economically important region in the world grind to a halt, world markets would crash, and everyone would lose trillions. It would make both the crash of '08 and the Great Depression seem quaint in hindsight.
Thankfully, it's incredibly unlikely to ever happen.