Why wouldn’t black attack g5 with 7h6 instead of be7 in queens gambit?

Diagram shows the more detailed answer. In short you either lose a pawn or you have a terrible pawn structure on the kingside.
#3
Fully agree.
In addition two other points.
Later in the game black can kick the bishop with ...h6, but if it is good or bad is debatable. ...h6 forces the bishop to trade or retreat, and ...h6 makes an escape hole for a king on g8, but ...h6 also weakes the position and allows attacks based on that.
Black is not forced to play 4...Be7 and can also ignore the pin 4...Nbd7 5 cxd5 exd5 6 Nxd5? Nxd5 7 Bxd8 Bb4+ black wins.

You're welcome.
@tygxc
Good points. Myself, I play Slav against 1.d4, but I think I've seen this trick before (where black gains a piece). Either in some video on QGD or in some other opening, as I wouldn't be surprised if it can occur somewhere else as well.
#7
Yes, here is a famous example with 6...h6
https://www.chessgames.com/perl/chessgame?gid=1049648
#10
Geller had told Spassky about the move 14...Qb7 in their preparation, but Spassky had forgotten that during the 6th match game against Fischer in 1972.
https://www.chessgames.com/perl/chessgame?gid=1044366