via http://alt-usage-english.org/excerpts/fxorigin.html
It is sometimes said that the dollar sign’s origin is a narrow “U” superimposed over a wide “S”, “U.S.” being short for “United States.” This is wrong, and the correct explanation also tells why the $ sign is used both for dollars and for pesos in various countries. The explanation is not widely known, maybe because not many people would think to look for it in a book called A History of Mathematical Notations, Volume II: Notations Mainly in Higher Mathematics by Florian Cajori (published in 1929 and reprinted in 1952, by Open Court Press). Cajori acknowledges the “U.S.” theory and a number of others, but, after examining many 18th-century manuscripts, finds that there is simply no evidence to support those theories. Spanish pesos were also called piastres, Spanish dollars, and pieces of eight. (The piece of eight was so called because its value was eight reales. Some countries made one-real coins by slicing pieces of eight into eight sectors; the still-current U.S. slang “two bits” for a quarter of a dollar may refer to this, although “bit” denoting any small coin — as in “threepenny bit” — was already in use.) The coins were circulated in many parts of the world, much as U.S. dollars are today. The coins were so well known that, when the U.S. got around to issuing its own silver coinage (U.S. dollar coins first appeared in 1794), it simply replicated the Spanish unit’s weight and hence value, and even one of its names; so it was natural to use the same symbol. Since three of the four names given above for the Spanish dollar start with p (and pluralize with s), it was natural for abbreviations like p and ps to be used. Sometimes ps was written as P — P with a superscript s. The superscript was a common way of rendering abbreviated endings of words — we see vestiges of it today in the way some people write “10th”. Now, what happens if you write P with a superscript s *fast*, because it’s part of a long document that you have to hand-write because you can’t wait for the typewriter to be invented, let alone the word-processor? Naturally, you join the letters. Well, now look at the top part of the resulting symbol. There’s the $ sign! Reduce the P to a single stroke and you have the form of the $ with a double vertical; omit it altogether and you get the single vertical. And yes, both these forms are original. Cajori reproduces 14 $ signs from a diary written in 1776; 11 of them have the single stroke, which was the more common form to the end of the century, and 3 have the double stroke. Although the $ sign originally referred to a Spanish coin, it was the revolting British -> American colonists who made the transition from ps to the new sign. (This is apparently also why we write $1 instead of 1$; it mimics the British use of the pound sign.) So, while it did not originally refer to the U.S. dollar, the symbol does legitimately claim its origins in that country