One of the things that confuses me about Optimizers is that I cannot understand that they think the only way to win DnD is through killing things.
Let's say the campaign is "Put the One Ring into the Fires of Mordor, or find another way to destroy it"
Sure, combat helps, but there are other solutions. We've all read them.
Maybe the campaign is "Someone controlled magic throughout your land and was oppressing everyone from being as great as they can be"
What's the optimized solution to that?
What's the optimized solution to "explore new worlds?"
Can you build me the perfect character for "A dragon kidnapped the princess. Please rescue her?"
You're conflating people who are optimizing for combat with people who enjoy making effective characters in general. DPR or other combat-oriented optimization (high AC, max hit points, etc.) is only one subset of optimization.
You can "optimize" for almost specific goal - in 3.5, you had the Diplomancer who could use CHA for damn near any ability check, the Rocket Monk who moved hundreds of feet each turn, or a ranger who could reliably track invisible, intangible creatures...
I think you'll find the majority of true optimizers - as opposed to the subset of rpg gamers who are simply obsessed with numbers or "winning" - are much more interested in "optimization towards concept" when making a character they actually
intend to play as opposed to white room theory-op where they're only interested in the intellectual exercise of number crunching and testing their cleverness. Optimization towards concept is the idea of making the most effective version of a specific character concept, or a version that best uses the mechanics of the game to accurately reflect the narrative character. To wit, the answer to "How do I make an optimized halfling wizard?" is not "Play an elf." On the other hand, the answer to how to play a dirt-stupid wizard who's still an effective caster may well be a high-charisma sorcerer and some narrative fluff.
You can even optimize towards building the best character to fit in with the rest of the party in terms of power level, skill set and/or narrative concept.
One thing that tends to get lost on online forums such as this is the distinction between "on paper" and "in-real-life" - if you frequented the old Char-Op boards on the WotC forums, a great many of the best Char-Oppers there would freely tell you that they would never bring one of their theory builds to a table unless they knew that the rest of the table was equally equipped.
I built a 3.5 swashbuckler 10/swordsage 10 with a spiked chain that adds three and sometimes even
four ability modifiers to damage, can teleport three times per combat, has a 2d6 sneak attack despite not having any rogue levels (even more depending on how the DM interprets the Daring Outlaw feat) and is a full skill monkey... However, the original version of the character and the only one I'd play at a table is a rogue/fighter/swashbuckler (a total of 5 non-rogue levels just to get free weapon finesse, a couple of extra feats and +Int to damage) who doesn't even bother to take Improved Trip to become a machine-gun-tripper...
As I'm not particularly a bigtime number cruncher, yet still enjoy optimization as a fun mental challenge, I often optimize towards the goal of creating an interesting character that meshes well with the rest of the party both mechanically and from a narrative perspective. One that will do what it's supposed to do in an effective fashion but not be useless in other areas and never overshadow the rest of the party.
In answer to your theoretical questions, those are overly-broad situations in which a variety of characters would be "optimal" at different points in the road toward accomplishing the stated goal...
1. "Someone controlled magic"...
Whatever is the most effective way to overcome that particular situation. It's too broad a question to provide a simple answer but the answers could be a character with enough charisma to inspire the general populace to great heroism to overcome the effect of the magic, or it may be being clever enough (high knowledge or history skill?) to find or build a powerful artifact to counteract it. Most likely, it's going to be having a party that synergizes well enough to be able to overcome a variety of obstacles both social and martial.
2. "Explore new worlds"... Again, a situation which requires a well-synergized party with a wide variety of skills and abilities - a diviner wizard would be helpful, and so would a ranger or druid with great survival skills. Even a knowledge cleric may be prove to be invaluable.
3. "Kidnapped princess"... Again, a ranger to track them or diviner wizard to find them, some kind of spellcaster to provide protection from or to neutralize the dragon's breath weapon, etc. And quite frankly, the "optimal" solution for resolving that one is entirely up to how the DM has set up the scenario.
Optimization by it's very nature requires that it be directed toward a very specific end - the "optimal" character for each of those situations is going to be a generalist capable of doing lots of different things because those situations require a wide variety of things be done to accomplish them. However, optimizing towards having high damage, or high AC, or being able to run circles around an opponent... Those are very specific goals, and the combat pillar of the game is obviously the easiest to optimize towards simply because it's the one with the most mechanical crunch and thus the one in which optimization is both the most possible and the most visible.