The Origin of the Dollar $ign
Towards the end of the eighteenth century the fledgling United States of America had not yet developed its own currency. In common with other colonial nations (notably Australia) they had to rely on the currency of other countries to conduct their commerce and trade.

Coins from Britain, Spain, Portugal, the Netherlands and other prominent trading nations were used for for everyday transactions - with all the attendant complications that exchange rates bring.

Perhaps the most ubiquitous coin was the Spanish 8 Real - the "piece of eight" of pirate fame.

8 Real obverse The happy chap at left, King Carolus (Charles) IIII of Spain, graced the obverse of the Spanish 8 Real coin of 1796.

Aussie 5c, to show scale
Aussie 5¢ coin to same scale
The 8 Real featured a number of different monarchs and reverse designs during the latter portion of the 18th and the first few decades of the 19th centuries. A common symbol amongst the reverse designs was a pair of pillars, or columns (representing the Pillars of Hercules in Gibraltar and Morocco)
8 Real reverse The reverse side shows these pillars. The left-hand column - or pillar - draped in a cloth banner in the shape of an "S", is clearly the inspiration for the ubiquitous dollar sign ($).
the dollar $ign
The 8 Real traded in the USA with a nominal value of one U.S. dollar (US$1) until well into the 19th century, decades after the establishment of the local currency.

As it was considered the equivalent of US$1, it is not surprising that the very recognisable symbol ($) on the reverse became a shorthand expression for the dollar itself.


Some Implausible and Downright Silly Alternative Explanations
It is unlikely, as has been suggested elsewhere, that the "$" symbol is a corruption of the "8" of "8 Real".
Such an explanation does not account for the central vertical pillar, nor for the missing portions of the loop which would transform an "8" into an "S".
Also, the above explanation (illustrated in the animation) is altogether too attractive to be discarded.

Discounted also are theories that the "$" is composed of Thomas Jefferson's "TS" monogram - or that it represents the letters "U" and "S" crossed - for United States. (The junction of the "U" wore out, you see, to reveal two bars.) Phooey!

Disagree? Comments? You may argue with me here if you wish.

Well then, why (some may argue) do some dollar signs appear with two vertical strokes, like so: 2 bar dollar sign Well... I would argue that this is just typographic fancy, and that most typefaces use a single column only.
Maybe (stretching a point here) it is intended to symbolise the twin pillars of the coin... but I think not. To me, the second stroke is just an artistic or typographical flourish. It certainly is not universal (...and it doesn't denote the country of origin!)

First postscript:
The 8 Real coin has particular significance to Australians, not just because it was used as standard currency in the colony (and proclaimed to have a value of 5 shillings), but because it was used as the basis for our first local coin, the Holey Dollar. More on that here.
Holey Dollar
2 bits Second postscript:
The 8 Real was known colloquially as "eight bits" and, as mentioned earlier, a "piece of eight".
Fractional denominations were in use, too. At left is a 2 Real coin of 1793 (with the "2", on its side, highlighted).

As the 8 Real was worth US$1, the 2 Real was worth a quarter of a dollar, 25¢...

...hence the colloquial American term for their quarter dollar: "two bits".

Third postscript:
Sydney Morning Herald - June 14-15 2003
SMH-14-15/6/2003
(SMH editorialising greyed - me pixellated)