Why it works
Black's early queen raid (4...Qh4+ 5.Kf1) won a tempo war on paper and lost it on the board: the queen crawled home while White developed. Now 8...O-O?? looks like finally reaching safety — and castles into a firing squad. 9.Qh5! joins Ng5 and Bc4 around f7/h7; the panicked 9...h6 lets White show the point: 10.Bxf7+! Kh8 11.Qxh6+!! gxh6 12.Be5# — the bishop that quietly took on f4 three moves earlier delivers mate along the long diagonal the g-pawn just abandoned. The king was safer in the centre.
Refutation
8...d5! is the classical King's Gambit remedy: give back material to blunt the c4-bishop and open lines for the defence. After 9.exd5 or 9.Bxd5 Black develops with ...Bf5/...Nd7 and stands only somewhat worse (engine −0.9) — a livable price for the earlier queen excursion. Castling can wait until Ng5 has been dealt with.