Why is h4 a good move here? [FEN ""]

1. d4 Nf6 2. Bf4 c5 3. e3 Qb6 4. Nc3 cxd4 5. exd4 Qxb2 6. Nb5 Na6 7. a3 Nd5                  8. Bc4 { I'm aware this was a blunder because of Nc3, but fortunately they didn't see it} 8... Nxf4 9. Rb1 Qxb1 10. Qxb1 Nxg2+ 11. Kf1 Nf4 12. Qc1 Ng6 13. Qe3 e6 14. Nf3 b6 15. Qe4 { This was the big mistake.} 15... Rb8 16. Nxa7 Bb7 17. Qe3 Bd6 18. Nb5 Bf4 19. Qc3 { This was another blunder, I had some hopes of creating discoveries against g7, but it ended up walking into a pin next move and the tactics worked against me because of it} 19... Rc8 20. Ne5 O-O 21. Nxd7 Bxh1 22. Nxf8 Nxf8 23. f3 { I had calculated this as trapping his bishop a few moves prior, not realising they had Bxh2... doh} 23... Bxh2 24. Qd3 Ng6 25.Nc3 Nf4 26. Qe4 Bg2+ 27. Kf2 Nc7 28. Bd3 f5 29. Qb7 Rd8 30. Qxb6 Bh3 31. Nb5 Nfd5 32. Qc6 Bf4 33. Nxc7 Nxc7 34. Bc4 Kf7 35. a4 Rxd4 36. Bb3 Rd2+ 37. Ke1 Rh2 38. Qd7+ Kg6 39. Bxe6 Rh1+ 40. Ke2 Rh2+ 41. Ke1 Bg3+ 42. Kd1 Rh1+ 43. Ke2 Bf1+ 44. Ke3 f4+ 45. Ke4 Nxe6 46. Qxe6+ Kh5 47. Qf5+ Kh6 48. Qe6+ g6 49. Qf6 Bh3 50.Qf8+ Kh5 51. Qg7 Bf5+ 52. Ke5 Re1+ 53. Kf6 Bh4+ 54. Kf7 Re7+ 55. Kg8 Be6+ 56.Kxh7 Rxg7+ 57. Kxg7 g5 58. a5 Bd5 59. a6 Bxf3 60. a7 Ba8 61. c4 f3 62. c5 f2 63. c6 Bxc6 64. Kf6 f1=Q+ 65. Ke5 Ba8 0-1


I've been trying to break 1700 on rapid for a while now. I just played this game where I was winning, but threw my advantage away on move 15.
15. Qe4 was the big mistake. I was winning up until then. I played it quickly as it just felt natural, stopping his bishop from fianchettoing. I knew that he had very little moves. He can't move the knight on a6, the knight on g6 can only go to e2, he can only move the dark-squared bishop to e2 and can't move the light-squared bishop. I assumed I could just take the a7 pawn when he moved his rook (I couldn't obviously), but after looking at it I understand why, as it develops his dark-squared. The thing is that the computer gives h4 as the best move here, and I don't really know why. I'm assuming it's to try and creates weaknesses on the kingside, but how are you supposed to know when to do that, and why is it better?
First, I assume that you mean 15.h4 (not h5).

If so, the main reason is that a lot of master-level chess is restricting your opponent's pieces, or in this case, even driving them back. The Ng6 has no good squares, and h5 driving to to a worse square is threatened. If 15...Be7; 16.h5 Nf8, and not only has the Ng6 been driven back, and still has no good squares, but now the Rh8 is doing nothing, and white may get a direct attack against the Ke8, which is stuck in the middle. A specific line is 15.h4 Be7; 16.h5 Nf8; 17.Rg1 g6; 18.Ng5 with the threat of Qf3 hitting f7 and the Ra8. If Bg5 then the dark squares are critically weak.

That leaves only 15.h4 h5, but then 16.Rg1 Bb7; 17.Bd3 already has critical threats since black's king is not going to have anywhere safe to hide, and if the N retreats, we are back to similar ideas as above (Nf7 and the Rh8 problems).

As far as how you know when to do this, there is no hard-and-fast rule, but in this case, you have to realize that the pieces can be restricted, which is pure analytical work.

P.S. Let me also reference chapter 7 from the book "Find the Right Plan with Anatoly Karpov" (beware of this book in that the title in Russian is "Plan and Evaluation", and the book really is not really much about planning). The title of chapter 7 is: "The most important law of chess". That "law" is: "Restricting the mobility of your opponent’s pieces (and in association with this: domination by your own) – is the most important law of chess."

That is the primary thing that is going on with 15.h4. In conjunction with that is the weak K, and the fact that the Ke8, in essence, divides the board k-side and q-side, and prevents pieces from helping out the other side.