By withdrawing the rook along the second rank, White keeps the black queen pinned, so she must follow it along that rank. (Black has no other options — his only other legal move, 1. … h3, loses to 2. Nf3#.) No matter which square she chooses, 2. Bb8 is mate.
Note that White must withdraw the rook all the way to the a-file in order for this to work. If it stops at any other square on the second rank, then the queen can capture it and find herself free to block (or capture) the checking bishop, escaping mate in two.