In iPhone OS 3 and higher, the phone's accelerometer isn't just for changing the orientation of the screen or shaking to shuffle. It can also be used to undo or redo typing.
If you type or copy and paste text, shake the phone and a menu will appear on the screen offering to Undo Typing or cancel. Tap Undo Typing to undo whatever text you just typed.
If you change your mind, you can restore the text by shaking again and tapping the Redo Typing button.
Shake to Undo works in Safari, Mail, Notes, Messages (SMS), Calendar, and similar apps.

