Coins of similar value were issued in Spain. They were called pieces of eight, because their value was divided into eight smaller coins. All these coins circulated freely in the colonies in both North and South America. In North America they were called dollars.
When the United States had been formed, the word dollar was adopted definitely for its unit of coinage, but the sign for the new coin was that of the old Spanish piece of eight. This sign showed the figure 8 (which resembles the letter S), crossed by two lines representing the Pillars of Hercules, the gateway between the Mediterranean and Atlantic at the southernmost tip of Spain. Thus the dollar sign really has nothing to do with the letter S, nor was it, as some people believe, originally formed by placing a narrow U over an S to form the monogram of the United States.
Dollar sign (Wikipedia)