A fun fact is you can figure out why battleships became obsolete just by comparing Iowa's guns to more modern systems.

A 16", 2,700 pound AP shell from an Iowa class battleship contains 40.9 pound of high explosives as the payload. A 1900 pound HE shell contains 153.6 lbs. of high explosive payload. The AP shell travels at a velocity of 2,425 fps on average. The HE shell travels at a velocity of 2,615 fps on average. An Iowa class ship traditionally stored powder and shells to fire each of its 9 guns 130 times before needing to be re-supplied. The maximum range of the cannon was 24 miles.

http://www.navweaps.com/Weapons/WNUS_16-50_mk7.php

By contrast, a Tomahawk cruise missile has a range of 1,550 miles and contains 1,000 pounds of high explosive. An Ohio-class guided missile submarine carries 152 of these on board. A single Ohio-class submarine can put more explosive payload on target than 3 Iowa class battleships firing their entire magazines dry (assuming AP shells), it can unleash its entire devastating salvo in about 2.5 minutes (as contrasted against an hour+ for a battleship), and it can do it from over 64 times the range as the battleship's cannons. Oh also the missiles are guided, and so can actually hit targets at extreme ranges where-as battleship were notoriously inaccurate outside 20 miles. At the Battle of Calabria the battleships on both sides fired a combined total of 335 large caliber shells, to one hit!

Of course the one advantage of the battleship is its shells are travelling on average ~3 times faster than the cruise missile is, and so it's far easier to shoot down a missile than it is a shell. But I hope with the above math you understand why naval planner's response to this was basically "Well if you can shoot down one of my missiles with 50% probability, we'll just fire off 5 at once and we'll still have >95% chance of landing a hit". And unlike with battleship shells, when a single missile hits you you're dead as a dodo - 1000 pounds of HE vs. 40 or 153 pounds for battleship shells.

Even if submarines and airplanes had never been invented, the big gun battleship still would've been rendered obsolete just from missiles alone. Even railguns aren't likely to change this, as we happen to have perfected hypersonic missiles at roughly the same time railguns became practical and HSMs are...I mean basically take all the advantages of a gun, and all the advantages of a missile, and put them into one thing. Hypersonic missiles are amazing/terrifying, and they will be the 'defining weapons' of 21st century naval war.

Also as an aside, can we talk about how damn cool the Ohio class SSGN is?! It's by far the coolest thing the navy currently owns IMO. It can hide in the ocean depths impervious to harm, pop to the surface and fire off 152000 pounds of high explosives, and then retreat to the safety of the ocean darkness again before its enemy even knows what happened. I own a model of it I keep on my desk and it's one of my favorite possessions.

Note: On Los Angeles class submarines the vertical launch tubes can be fired with ~1 second delay per round. So assuming the navy's technology on the Ohio's is still held to the same standard, that's 152 seconds to fire all 152 missiles or 2.5 minutes to fire the whole stock.