Complex sentence: There, Link frees Zelda and nearly defeats Ganondorf, but he destroys the castle in an attempt to kill Link and Zelda.
Split into simpler sentences: There, Link nearly defeats Ganondorf and frees Zelda. However, Ganondorf attempts to destroy the castle to kill Link and Zelda.