It's just like any science. Trail and error with strategic, methodical approach. And lot of investment dollars. Control for variables--only try one "new" thing out at time.
Width: This one you can pretty much figure out standing on decks at the shop. Figure out what size range feels the best to you.
Wheelbase: Pick some baseline...14.25, for example. When your done with that deck, go slightly up/down in size (e.g. a 14.38 or 14.0) for the next one. Which did you like better? Repeat until you find your "zone."
Wheels: Pick a wheel that comes in lots of sizes (Spitfire Classics). Do the same thing as wheelbase, but now with wheel sizes. Once you have your wheel size figured out, start trying different wheel shapes in that size.
Trucks: Buy lower trucks when possible (Indy Forged v. Standards, Thunder Lights v. Teams, etc.), because you can always make a lower truck taller with a small riser, but you can never make a taller truck lower. Then start plugging your way through different trucks.
To find your "best" set-up (and to rule other stuff out) takes a lot of time and money. Is it worth it? That's up to you. I never intentionally set-out to find my "best" set-up, it just happened over time trying different stuff out because of curiosity. And as others have said, it's situational and always a trade off. 14.38 wheelbase is my all-around fav, but I can 360 flip much better on a 14.1/14.25.However, smaller WB feel way too cramped for other things for me, esp. ollies. For mini ramps I like a slightly wider board with slightly bigger wheels. For big transition I like something even bigger (not doing much of that anymore). The point: No one set-up is going to magically make everything work perfectly. It's all a matter of compromise, and figuring out where between "give" and "take" you want to position yourself.