For reasons of safety. Venice was founded as the Western Roman Empire collapsed. As early as the late 2nd century AD, the nearby mainland cities were being constantly overrun and plundered and their citizens killed by invading Germanic tribes. This trend accelerated by the late 5th century AD as the Visigoths, Huns and Lombards invaded in wave after wave.
Eventually the remaining Romans sought refuge on the nearby islands that had previously only been occupied by fishermen. The surrounding water and isolated islands made it easier to defend and of less interest to the invading tribes. The new occupants gradually expanded what became Venice by employing a system of canals and bridges, while joining and expanding the islands using pilings to support the building structures.
The process is not very different to the steel pilings used in cities like New Orleans where the land does not sit much above the water table. Can you tell Venice is one of my favourite cities? And that I am a history buff?