Because Kim's reign is predicated on maintaining credibility with his generals. He does that by rattling his saber and extracting economic concessions from the global community in general (and the US in particular).
Why he needs to go precisely this far is a good question. Possibly because Trump has consistently misplayed his hand and made a series of stupid bluffs that were quick and easy to call. Kim is probably testing the edges of his geopolitical box, figuring that it's a bit roomier than he'd previously calculated.