The 49ers can win Super Bowls with Kaepernick. The 49ers cannot win Super Bowls with Colt McCoy, Blaine Gabbert, or <insert free agent QB>. They also probably cannot win with any rookie QB they might've signed in the next couple years if Kaepernick walked.
Two other things about this deal make it smart. By not waiting another offseason, the 49ers eliminated the chances that Russell Wilson or Cam Newton, both expecting huge contracts of their own, from signing an even bigger contract extension. Kaepernick signing first all but guarantees that he'll have the cheapest contract of the three. It was somewhat by necessity - being a 2nd round pick, Kaepernick had no 5th year option that the Panthers are using on Cam, and was signed a year earlier than Wilson and thus was going to be a free agent a year earlier. Still, this only benefits the organization, as they'll get the cheapest deal of the bunch. Second, salary caps are going to increase at a record pace over the course of the next couple years. There's going to be plenty of room to fit Kaepernick under the cap, and even if they'll have to make some cuts elsewhere to afford him the 49ers are so loaded with talent I doubt it will matter too much.
Regardless of the "you can't win without an elite quarterback" mantra being proven (?) false, you still need a good quarterback to separate teams like the Rams from the Seahawks. Losing Kaepernick might be disastrous; keeping him at a high price probably won't be. As long as Kaepernick can keep his personal issues out of the way, it should be a fine deal for both parties.