Actually, you can directly calculate the optimal odds to win in TicTacToe against a random opponent and it turns out that you would win 191 out of 192 games and draw the last one when beginning.
For that -unintuitively- you have to start in a corner, lets say top left:
O . .
. . .
. . .
Then one can see that the only way to draw for the second player is to put the
X in the middle (so chance for a random opponent: 1/8). If he doesn't, O can force a win, e.g. after
O X .
. . .
. . .
O can put the marker in the middle, forcing X on the bottom right and then putting an O on the middle left, creating 2 possibilities for a tic-tac-toe.
One can easily also check the other options for X to go wrong and will confirm that only an X in the middle will hold a draw, but to keep the answer brief I will not proof it here.
Then, we can put our next "O" in the top middle, leading to
O O .
. X .
. . .
where the second player needs to put an "X" in the top right (chance 1/6 for a random opponent)
Then we place our "O" in the bottom left to simultaneously deny "X"'s thread and make a thread on our own:
O O X
. X .
O . .
So at this point a random opponent has a 1/4 chance to save the game. After that, we have to play middle right to draw, as we have no more chance to get any Tic-Tac-Toe even with cooperative play from X.
The chance to win is therefore 1 - 1/8*1/6*1/4 = 191/192.
Remark: One can easily see that this is the best strategy for a win. The total number of moves for "X" are 384 (8 on turn one, then 6, then 4, then 2), out of which with this strategy only 2 ways draw. When "O" starts in the middle, with perfect play all 4 corners can draw for "X". Analogously one can justify every subsequent decision for "O".