Paste Bracketing is a way for a terminal emulator, such as iTerm2, to communicate where text the user has pasted (e.g., with Cmd-V) begins and ends.
It is useful in a text editor that automatically adds indentation. Since pasted text is already indented, it would normally get double-indented. With paste bracketing enabled, the indentation pasted in gets preserved.
How can things get all screwed up?
Paste bracketing must be enabled and disabled by a program (such as emacs or vim). This is done by an invisible control sequence originated by such a program. If this is done in an ssh session that unexpectedly terminates while the editor is running (such as because of a network problem) then paste bracketing is left enabled even though the program now receiving input (likely your shell) never asked it to be turned on.
The result of this unfortunate situation is garbage characters (00~ and 01~, typically) appear at the beginning and end of pasted text. The user is perplexed.
How do I turn it off?
The easiest way is to reset your terminal with Session > Reset (Cmd-R). If you have Shell Integration installed, it will also prompt you to turn it off automatically if it gets left on when an ssh session dies unexpectedly.
Why did iTerm2 ask if I wanted to turn it off?
Shell Integration enables iTerm2 to detect when the current hostname changes, provided it is installed on both the machine you ssh from and the one you ssh to. If paste bracketing is enabled when the hostname changes, that is a red flag that an ssh session has ended unexpectedly. iTerm2 will ask if you'd like to turn it off. You almost certainly do.
To enable paste bracketing, use this control sequence:
When paste bracketing is on, pasted text is prefixed by esc[200~ and followed by esc[201~.