The adverb thereby shows cause and effect: "She forgot to tie her shoes, thereby tripping and falling down the stairs."
Use thereby to connect two events: because of A, B happened: "Matt walked around with the frying pan on his head, thereby causing him to walk into a wall." Thereby is used in the infamous saying, written by Shakespeare: "And thereby hangs a tale" — a humorous way to let your listeners know they are about to hear an extremely long explanation as to why something happened.