user16771: 
Is not bishop to e2 better? Why does the kingside has to be weakened like this?
Thanks everyone for your answers. You all argue that the knight must remain on f4 so h4 prevents kicking it out. However, I just found another game in which h4 is played and this time there is no keeping the knight on f4. Could someone tell me what else happens here?


user16804: As a novice, it's hard for me to see why 1. Be2 g5 2. Nd5 is putting White at a major disadvantage, but I do feel it puts White on the defensive. Black has gained space and potentially a kingside attack, but may be overextending. White's knight is centralized, and black may trade it away leading to a centralized pawn structure for White with a potential target pawn aiding the Black's light bishop and weakening White's. White needs to protect their center while anticipating heavy kingside pressure in terms of pawn pushing backed by rooks.
Compare that to 1. g5, where White seems to be restricting Black's expansion. This may allow White to develop into a stronger attack without worrying about the kingside pressure.
I'm unsure about responding to g5 by moving the knight to the h-file. I don't see any benefits to White's position there. 

user13025: With h4 you prevent g5, which would kick your knight.

user14202: As mentioned, it's all about keeping the Knight on f4.  That outpost needs to be maintained and ...g5 is stopped by h4! Yes, g4 is weakened but to quote Bobby: "You have to give up squares to get squares".
Also note that if Black plays ...h6 hoping to play ...g5 you can play h5 and that knight is not going anywhere.  
Piece activity can be more important that weak squares or even weakened structures.  You can go over the Kasparov - Short world championship match an see how Short took on doubled pawns, etc. but was compensated by good pieces.

user15296: You're trying to analyze the very equal position with no significant tactical potential. Depending on minor tweaks of your engine settings, you may get a few "good" moves, including Be2, Ba3, c5 -- all approximately equal. 
Computers at lichess have limited resources, hence they spot only obvious stuff, and have a limited precision when evaluating moves. 
If you move h4 -- you're down about 0.1 pawn, I would not lose a sleep about that, Be2 is good enough and you should not worry what stupid engine says =)
Disclosure: I'm actually running one of the lichess analysis boxes, so I took a deep dive into the details. Here's what I found:

From your screen shot, you're running analysis on your local iPad, which is slow and may take some time to arrive to the good result. It would be much preferable to run the server side analysis, much faster and more precise.
I have found the game in question among your games and analysed it using various engines available. Most of the engines recommend c5 as the best continuation for White. However, for the lichess analysis we use a very conservative settings of Stockfish ("Analysis Contempt" is turned Off), this changes the focus from the active attacking moves to the "safe" defensive ones. And h4 is one of those nice safe moves.

As I have said earlier, it all depends on the minor tweaks of the engine parameters, the score difference is negligible and h4 is no better and no worse than a few other moves -- play what you like and don't worry about what computer says.

Answering the second part of your question, here's my analysis:

Bd3 seems to be "the best", with h4 and Be3 sharing the second place. Actually, while analysis was running, 4 or 5 top pretenders constantly swapped their places, sometimes h4 was on the top. Probably, if I run the analysis deeper, there will be a few moments when any of the top 5 moves will be declared "the best".
All in all, the analysis is not exhaustive, and it does not guarantee to give you the "absolute best move". The main purpose of the analysis was to spot your mistakes (8. h3? was clearly a mistake, losing 0.5 pawn), and propose something better, not necessarily the best.
Here's the analysis @ depth 24, h4 is way below.


16771: <p><a href="https://i.stack.imgur.com/NYgRk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NYgRk.png" alt="enter image description here"></a></p>

<p>Is not bishop to e2 better? Why does the kingside has to be weakened like this?</p>

<p>Thanks everyone for your answers. You all argue that the knight must remain on f4 so h4 prevents kicking it out. However, I just found another game in which h4 is played and this time there is no keeping the knight on f4. Could someone tell me what else happens here?</p>

<p><a href="https://i.stack.imgur.com/p9LyO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/p9LyO.jpg" alt="enter image description here"></a></p>
 16804: <p>As a novice, it's hard for me to see why 1. Be2 g5 2. Nd5 is putting White at a major disadvantage, but I do feel it puts White on the defensive. Black has gained space and potentially a kingside attack, but may be overextending. White's knight is centralized, and black may trade it away leading to a centralized pawn structure for White with a potential target pawn aiding the Black's light bishop and weakening White's. White needs to protect their center while anticipating heavy kingside pressure in terms of pawn pushing backed by rooks.</p>

<p>Compare that to 1. g5, where White seems to be restricting Black's expansion. This may allow White to develop into a stronger attack without worrying about the kingside pressure.</p>

<p>I'm unsure about responding to g5 by moving the knight to the h-file. I don't see any benefits to White's position there. </p>
 13025: <p>With h4 you prevent g5, which would kick your knight.</p>
 14202: <p>As mentioned, it's all about keeping the Knight on f4.  That outpost needs to be maintained and ...g5 is stopped by h4! Yes, g4 is weakened but to quote Bobby: "You have to give up squares to get squares".</p>

<p>Also note that if Black plays ...h6 hoping to play ...g5 you can play h5 and that knight is not going anywhere.  </p>

<p>Piece activity can be more important that weak squares or even weakened structures.  You can go over the Kasparov - Short world championship match an see how Short took on doubled pawns, etc. but was compensated by good pieces.</p>
 15296: <p>You're trying to analyze the very equal position with no significant tactical potential. Depending on minor tweaks of your engine settings, you may get a few "good" moves, including <code>Be2</code>, <code>Ba3</code>, <code>c5</code> -- all approximately equal. </p>

<p>Computers at lichess have limited resources, hence they spot only obvious stuff, and have a limited precision when evaluating moves. </p>

<p>If you move <code>h4</code> -- you're down about 0.1 pawn, I would not lose a sleep about that, <code>Be2</code> is good enough and you should not worry what stupid engine says =)</p>

<p><strong>Disclosure</strong>: I'm actually running one of the lichess analysis boxes, so I took a deep dive into the details. Here's what I found:</p>

<ol>
<li><p>From your screen shot, you're running analysis on your local iPad, which is slow and may take some time to arrive to the good result. It would be much preferable to run the server side analysis, much faster and more precise.</p></li>
<li><p>I have found the game in question among your games and analysed it using various engines available. Most of the engines recommend <code>c5</code> as the best continuation for White. However, for the lichess analysis we use a very conservative settings of Stockfish ("Analysis Contempt" is turned Off), this changes the focus from the active attacking moves to the "safe" defensive ones. And <code>h4</code> is one of those nice safe moves.</p></li>
</ol>

<p>As I have said earlier, it all depends on the minor tweaks of the engine parameters, the score difference is negligible and <code>h4</code> is no better and no worse than a few other moves -- play what you like and don't worry about what computer says.</p>

<hr>

<p>Answering the second part of your question, here's my analysis:</p>

<p><a href="https://i.stack.imgur.com/Hunta.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hunta.png" alt="enter image description here"></a></p>

<p><code>Bd3</code> seems to be "the best", with <code>h4</code> and <code>Be3</code> sharing the second place. Actually, while analysis was running, 4 or 5 top pretenders constantly swapped their places, sometimes <code>h4</code> was on the top. Probably, if I run the analysis deeper, there will be a few moments when any of the top 5 moves will be declared "the best".</p>

<p>All in all, the analysis is not exhaustive, and it does not guarantee to give you the "absolute best move". The main purpose of the analysis was to spot your mistakes (8. h3? was clearly a mistake, losing 0.5 pawn), and propose something better, not necessarily the best.</p>

<p>Here's the analysis @ depth 24, <code>h4</code> is way below.</p>

<p><a href="https://i.stack.imgur.com/2Ywn2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2Ywn2.png" alt="enter image description here"></a></p>
