Why do steamships have masts?

Steam-liners had masts for mainly four reasons (although they did serve other purposes, this varied ship to ship)
  1. Late 1800 and early 1900 Steam-liners had masts to support the wireless telegraph antennas, these were strung between the two masts. Generally, the longer the ship, the most distance between masts, the longer the wireless antenna, and the more sensitive and powerful the wireless telegraph could be.
  2. The masts carried the vessels flag, identifying her home country. This was actually required by maritime law at the time as one of the only ways of identifying a ship from a certain distance. Many lines(shipping companies) also put their corporate flag atop the masts as well.
  3. The masts carried marker lighting. Because the masts were very tall(<100 feet) lighting atop them could be used to help locate other ships nearby if the seas swells were large and obstructing the hundreds of lights on the ships decks and promenades. Because RADAR did not exist yet, this was one of the only ways of collision prevention at night.
  4. The masts carried the Crows Nest. Yes, even early 20th century ships had these platforms near the center of the mast to help prevent collision with other ships and floating obstacles (icebergs).