Why white retreats the knight at the beginning of the game? This is one variation from Bird's Opening:


f4 e5 2. e4 exf4 3. Nf3 d6 4. d4 g5 5. h4 g4  



  [FEN "rnbqkbnr/ppp2p1p/3p4/8/3PPppP/5N2/PPP3P1/RNBQKB1R w KQkq - 0 6"]

The most popular move is Ng1 instead of Ng5. Am wondering why retreating the knight is a good idea. Doesn't this move violate some opening principles in developing your pieces? After white retreats the knight, he has only three pawns developed while black can continue with Bh6, developing the bishop whilst supporting the f4 pawn.
The opening is called King's Gambit and is usually reached with a slightly different move order after 1.e4 e5 2.f4....

It used to be popular a long time ago (100+ years) for its potential of wild games, but is probably slightly incorrect and not a good choice if your opponent knows what to do.

Arguing with general opening principals is not really meaningful here, because the opening is very concrete/tactical. 

After your suggested Ng5 for instance you'd have to be prepared for f6 after which the knight is attacked and will be lost due to lack of retreating squares. White would get 2 pawns for the knight, but that won't be enough.

Retreating the knight, while not ideal, is a better option.