Complex sentence: During the 16th century it was attacked and sacked by the Ottomans and Barbary pirates; to help defending the village against such attacks a castle was built on the seafront.
Split into simpler sentences: During the 16th century it was attacked and sacked by the Ottomans and Barbary pirates. To help defend the village against such attacks a castle was built on the seafront.