If you believe that U.S. Navy had its genesis in the 1794 Naval Act, that particular piece of legislation dictated that six hulls were to be laid down and completed unless a peace treaty with the Dey of Algiers was met. Such a peace treaty was reached as were similar agreements with the other Barbary states.
When the Department of the Navy was officially created again by an act of Congress in 1798 the United States was ostensibly at peace with all the pirate states. If might made right, why did we along with other great powers continue to pay tribute to these states for decades? You can't really say the United States was simply growing the young navy to eventually take down the pirates because Thomas Jefferson being the huge anti-federalist small government fool he was, cut the navy and army greatly in an effort to shrink the size of the federal government.
What explains the dire need for a blue water navy? The answer of course is the quasi-war with France that had steady worsened after the nascent United States signed peace treaties with both Great Britain and Spain in the mid 1790s. Our small navy was designed to protect American ships in the West Indies not the Mediterranean. This was a realistic aim, after all if Great Britain the world's preeminent navy could not be bothered to stop piracy why should we be expected to do any better? Despite the distractions of ongoing Franco-European warfare Britain never was seriously challenged at sea.
The Barbary Treaties refer to several treaties between the United States of America and the semi-autonomous North African city-states of Algiers, Tunis, and Tripoli, under the rule of the Ottoman Empire, known collectively as the Barbary States.
Treaty with Algeria (1795)
Treaty with Tripoli (1796)
Treaty with Tunis (1797)
Treaty with Tripoli (1805)
Treaty with Algeria (1815)
Treaty with Algeria (1816)
Treaty with Tunis (1824)
Treaty with Morocco (1836) The Navy DOES NOT exist because of pirates, although it was early on used against them. If we invoke the wisdom and lore of our early founding fathers we need to be clear what the truth of the situation was.