Why in the past were European ships built with high wooden "castles" fore and aft?
to have better view
to manage the deck more easily
to improve ship defense
to improve ship stability
These were built to better resist boarding, commonly used in the naval warfare (especially by pirates). Boarders needed to attack these castles with great difficulty, while archers or harquebusiers could sweep the enemy decks.