In late Antiquity the north-east of the Italian peninsula suffered many invasions. The wars caused people to move to the safer lagoon areas, and hence to the foundation of Venice.
Venice was a republic from the beginning, but in a time when hereditary power was the norm, why did Venice become a republic and not a monarchy?