The sacrifice works when several conditions line up: a bishop aimed at h7, a knight ready to jump to g5, a queen that can reach the h-file quickly, and the defender lacking the resources ...Kg6 or ...g6 to survive. After 1.Bxh7+ Kxh7 2.Ng5+ the king is dragged into the open and White's attack often crashes through.
Knowing the Greek gift cuts both ways: as the attacker you learn to recognize when the pieces are in place, and as the defender you learn which setups (a knight on f6, a pawn already on h6, or a queen guarding h-file squares) make h7 immune. It appears in countless real games arising from the French, Caro-Kann, and Queen's Gambit structures.