A 51% attack happens when blocks are being found way faster than the difficulty allows. Raise the difficulty, and bang - 51% is out of commission, at least until he can get his speed up again.
Huh? A 51% attack could also be called a 51% takeover, and happens when 1 person owns 51% of the hashing power, and takes control of the entire network (rewrites the blockchain). The larger the network is, the harder for 1 person to own 51%. It's a LOT harder to gain 51% of a 200TH/s network than it is a 2TH/s network, for example. A larger network is inherently more resilient to a 51% takeover, you see?
A larger difficulty is just a side effect of that larger network. The difficulty of that 200TH/s network will be 100x that of the 2TH/s network, right? The difficulty itself doesn't actually protect against an attack (or takeover), but the factors that caused the difficulty to raise are what protect us.