If few best computer players would be playing against themselves, chances of white winning would depend on the opening used. That way after simulating thousands of games the best opening would be found that is strictly better than the others. Is there a flaw in this procedure? Has this ever been done before?
You may underestimate the number of games you need to determine the "best" opening by simulation. The differences between different openings are very small and to get a solid statistical judgment a few thousand games for each opening may be insufficient.
Then comes the question of the best response: There is an opponent, after all, and to build an opening book you must test for the strongest responses.
Still, this is all statistical and we know that it is not possible to solve chess computationally at the time being. A deep analysis may find a flaw in the "best" opening that is out of sight for current chess engines.
To your last question: For the chess variant "Schoolbook" (a variant of the Carrera-Capablanca type with rook-knight and bishop-knight compounds) its author Sam Trenholme has started to build an opening book using the method you propose, see http://www.chessvariants.org/index/msdisplay.php?itemid=MSschoolbook (comment at the bottom of the page).
Such a process would only find out which opening works best against the current version of itself. Nobody cares how well a computer plays against itself.
For some computer vs computer events (like TCEC), it is common practice to pick some opening position after 8 moves or so, and then play without opening book.
For customers, people who buy engines to play games against it, it is most important that it plays a wide variety of openings (variety is more fun), and that it is very up to date with current theory, for practice reasons.
So the main people interested in really great opening books for computer vs computer play are the kind of people who run their engines 24/7 on sites like Playchess to play against other computers, trying to improve their computers' ratings. They basically do this process manually, by watching the results and updating the opening books by hand where needed.
And on top of all that, remember that chess is most likely a draw. All the very theoretical, forced, deep lines that computers are great at analyzing out (like the Najdorf Poisoned Pawn, say) tend to lead to forced draws in all lines. Once everybody knows too much, they have to switch to something less well known.
If the question is asking why computer engines don't use much narrower opening books that could theoretically be analyzed deeper (and thus be objectively 'better'), the answer is simply that it actually makes the engine weaker because the chance of leaving the book becomes greater with a deep-but-narrow book (as suggested) instead of a shallow-but-broad one.
You could come up with an incredibly detailed book for one specific mainline opening (and some people have tried this, a notable example being for the Halloween Gambit), but there are several problems:
- If the opening your engine will play is known because there's really only one line used, it's easier to research that and include a refuation in a competing engine's book.
- If your engine only has a very narrow book, then it's relatively easy to generate an opening book that is broader and using a small amount of randomness in the engine would provide a fair chance of deviating and staying in book long after your engine is thinking for itself (which is generally a bad idea for an engine in the opening).
- If your engine knows a certain opening up to move 50, then it's not difficult for a competitor to take that book and expand that one opening up to move 55, thereby having a decent advantage. It's a real problem when your book contains thousands of different lines, though.
As a result of these, having a broader book is a benefit both offensively (you might be in book longer) and defensively (less likely to be brought out of book quickly), and requires only a small sacrifice in depth.
Time, availability of faster computers, and progress in Artificial Intelligence have invalidated my previous answer.
With Alpha Zero and Leela Zero we now have programs learning Chess strategy and openings from intensive self-play and giving winning percentages for moves and positions.
It is possible now (i.e., in 2018).
EDIT: However, even the above-mentioned engines have not yet solved Chess. They also produce quite a variety of opening lines and do not slavishly play one and the same line every time.
Yes, there's a flaw, and it's that the opponent also has a move. At best, you can only choose your first move (and only then if you are White). After the first move, because the opponent is also trying to maximize his chances of winning, he's not going to pick an opening which you win more often than not. Therefore you can't just find the opening that gives you the best result when you play against yourself, and play only that opening - the opponent will not allow it.
At best, you might be able to say "with 1. e4 I maximize my chances of winning", but that's already done by all computers.