That weird lowercase "s" in old style type

What’s the story with that lowercase ‘s’ that looks like an ‘f’ in old documents and whatnot? Was it just the way they wrote ‘s’ back then or was it only used in specific circumstances?

Lastly…why?

It’s called the “long s”:

http://en.wikipedia.org/wiki/Long_s

The Master speaks: Why did 18th-century writers use F instead of S?.