As described in this answer, newer versions of macOS now have native support for rebinding Caps Lock to Escape. Thus it is no longer necessary to install third-party software to achieve this.
Here's my attempt at a comprehensive, visual walk-through answer (with links) of how to achieve this using Seil (formerly known as PCKeyboardHack).

In the popup dialog set Caps Lock Key to No Action:



And you're done! If it doesn't work immediately, you may need to restart your machine.
##Impressed? Want more control?
You may also want to check out answered 2011-12-08T20:57:01.390
In order to actually swap the escape key with the caps lock key (not just map one to the other) using both PCKeyboardHack and KeyRemap4MacBook, you have to follow the instructions in this thread, mapping the caps lock key to a keycode not used by the keyboard but accounted for by KeyRemap4MacBook (eg. 110). Then, in PCKeyboardHack, select the appropriate option that maps that keycode to escape (in the case of 110, it's "Application Key to Escape"). Here's what your KeyRemap4MacBook preferences should look like (provided you've selected the "show enabled only" checkbox).

I originally attempted to post this information as an edit to cwd's excellent answer, but it was rejected. I encourage anyone who wants to go the route that I describe to first read his/her response.