The reason for playing ...Nh5 is to have the option of playing ...Nf4, where ...exf4 would unleash his usually bad KID bishop. Case in point is the Bayonet Attack:
[FEN ""]
[Event "?"]
[Site "?"]
[Date "?"]
[Round "?"]
[White "?"]
[Black "?"]
[Result "*"]
1. d4 Nf6 2. c4 g6 3. Nc3 Bg7 4. e4 d6 5. Nf3 O-O 6. Be2 e5 7. O-O Nc6 8. d5 Ne7 9. b4
The main move is 9...Nh5, where in some lines black plays for ...Nf4, where a move like Bxf4 would be made worse by the fact that the absence of the b2 pawn gives even more potential to black's dark-squared bishop.
Your suspicion that the Nh5 can be loose is correct; note that in the line you describe, black needs to play ...Qe8 before going for ...f5, but on the other hand, 7...Nh5 disturbs white's position, as immediately developing the f1 bishop runs into 8...Nf4.
Generally, black would prefer ...Nh5 because it's more active; when it's not possible (say in the main line after 9.Ne1), ...Nd7 works to slow down white's c5, and ...Ne8 allows it, but can defend d6 and c7 (which can be important as white often goes for c5, cxd6, Nb5, Nc4 and Rc1).
Anyway, the differences between each choice of knight move are theoretically rather subtle, as you often find the knight moving back into f6; that said, picking the 'wrong' square gives white the option of changing his plan. In other words, one could probably argue, in some sense, that you don't pick the option that is favorable, but rather eliminate those that are not.
For example, back to the Bayonet Attack, after the main move 9...Nh5, white plays 10.Re1 to meet 10...Nf4 with 11.Bf1, and now 11...f5 runs into 12.Bxf4 and 13.e5. So the main line runs 10...f5 11.Ng5, and black can go for 11...Nf4 here, but it's not clearly favorable to 11...Nf6 (which is in fact the main move; ...Nf4 is considered a serious alternative). That said, 9...Nd7 is considered inaccurate, and white can attempt to highlight this with 10.a4, and simply carry on with his queenside attack (10.Nd2, which transposes to positions reached through 9.Nd2, sort of lets black off the hook, as white had no immediate motivation to move his king's knight, as black is not 'threatening' 10...Nh5)
A theoretical note: the immediate 9.Ne1 and 9.Nd2 were the old main lines as white wanted to stop 9...Nh5; the modern Bayonet Attack argues that white can allow it.