Venice started simply because the Venetian Lagoon was the easiest way to flee from Germanic tribes invading after the decline of the Roman Empire. Those in the lagoon formed a community that grew, formed laws, and became the city of Venice.
The historian John Deacon in the 11th century stated that a certain Paolo Lucio Anafesto was proclaimed dux or duke in 697, making him the first Doge of Venice. This is disputed, since Constantinople (with Rome's fall, the Byzantine Empire had more authority over the former Roman Empire) confirmed Orso Ipato with the title dux in the early 8th century. He is seen as the first official Doge. Although Orso's son Deusdedit ruled after him, any attempt to create a dynastic rulership ultimately failed. The Doges were elected for life by the Great Council of Venice, a parliament of aristocrats and merchants.
Venice was recognized as its own entity, separate from the Byzantine Empire, in 840 when it signed a commercial agreement with Lothair I of the Carolingian Empire. This Pactum Lotharii asked that Venice help control the Slavic tribes to the east; in return, Venice was safe from invasion from the Frankish Empire. The Pact also forbade the sale of Christians to Muslims. Venice had established a thriving slave trade, capturing people in Italy and selling them to Moors in North Africa. After the Pact, Venice captured Slavs and other Eastern European non-Christians. Records show a female slave was worth 1.5 grams of gold, or about 1/3 of a dinar. Castration houses were a business in Venice, preparing slaves because of the high demand for eunuchs.
Another big business was ship-building, and Venice perfected this process in a big way. Ships were important for moving everything, including thousands of willing passengers from Europe to the east during the Crusades. Venice was involved in just about every Crusade, providing (renting) ships to the ventures. The Fourth Crusade was particularly crucial in this regard, with the Doge Enrico Dandolo taking over the Crusade and using it for his own ends.
I suppose this is a good time to segue to a larger discussion of the medieval slave trade. Venice was not alone in this lucrative market, as you will see.