This is a brief answer (for me) to point out that:
Your question is not really concerned with photosynthesis but is actually about the choice of the carbon constituents of living cells.
First you talk about photosynthesis as if it is a single process, however it is two separable processes:
The Light Reactions convert solar energy into chemical energy (in the form of ATP and NAD(P)H).
The Dark Reactions use the chemical energy to reduce carbon dioxide and elaborate it to more complex molecules.
Photosynthesis is so elaborate chemically that it clearly was not the first process by which living organisms managed to convert environmental energy into a usable form. So the question becomes:
Q. Why is chemical energy trapped by living organisms used to make
compounds such as glucose 6-P?
and giving what may at first sight seem to be a frivolous answer
A. Because glucose 6-P and its precursors and metabolites were suitable molecules for building the structural components of cells, that had arisen early in evolution.
So the question becomes:
Q. Why did the structural components, energy storage, genetic information
etc. of cells evolve to employ the particular molecules that we find
today, most of which can be formed from glucose metabolites?
And that is a very broad question about a very speculative area of chemical evolution, which cannot be summarized here.
In general one would imagine that the answer is related to the carbon components available in the environment and the possibilities of chemical transformations. However the trap is that one ends up arguing that things are the way they are because that was best. Which is all very well until one discovers dirty little secrets such as the fact that archaea evolved different chemical constituents for their cell membranes.
My first degree was in chemistry. Since becoming a biochemist/molecular biologist I have almost never talked in terms of overall chemical formulae of molecules in the manner of the question. It has seldom been a useful way to approach biochemical reactions or intermediates. What has been more important is to look at their structures and ask how they lend themselves to their functions or interconversions.