Oxygen is a byproduct of photosynthesis because photosynthetic organisms on Earth use water as the electron donor. However, the first photosynthetic organism emerged from ocean where chloride is also abundant. Considering that the electrode potentials of chloride and water are quite close, is it just a coincidence that photosynthetic organisms oxidize water instead of chloride? Although oxidation of chloride can produce dangerous byproducts like chlorine gas and hypochlorite, further oxidation can turn them into perchlorate which is quite stable. Is it possible for extraterrestrial plants to produce perchlorate salts instead of oxygen gas, while extraterrestrial animals ingest perchlorate instead of breathing oxygen gas? My question is not limited to perchlorate, but can be extended to other oxidants like nitrates, permanganate.
Considering that the electrode potentials of chloride and water are quite close, is it just a coincidence that photosynthetic organisms oxidize water instead of chloride?
No, it's not a coincidence. Chloride may be abundant, but water is way more abundant. And the point of oxidizing the oxygen in water is to crack the hydrogens off of it; oxidizing chloride doesn't get you the same benefits, unless the environment is highly acidic. Otherwise, you don't get hydrogen, you get elemental sodium or calcium or potassium, and nobody wants that!
Now, you might get organisms producing chlorine for other reasons, which can be cool, but it doesn't make sense as a feedstock for basic photosynthesis.
At least, not in a world dominated by close-to-neutral water.
If you are willing to go more exotic with your alien biochemistry and handwave a world where most of the liquid is HCl instead of H2O, then it makes perfect sense. That's a little hard to arrange, but you can get a similar effect with a sulfuric acid ocean--which is exactly what you would get if you cooled down Venus. Chloride and fluoride salts are not stable in sulfuric acid solution, so you do actually end up with a lot of hydrochloric and hydrofluoric acid, and it's much more plausible that you could get organisms using HCl as their hydrogen source for photosynthesis.
Leaving chlorine and chlorates behind, though, other complex oxidizers are entirely plausible. Oxygen itself, for example, is extremely poisonous to anaerobic life. Early oxygenic photosynthesizers got away with producing it because they could eject it into the environment where it diluted enough to not kill them for long enough to evolve increased resistance to it (while killing off their competition at the same time). Given that things like nitrates and phosphates are biologically useful materials anyway, it is not much of a stretch at all to imagine that life on a different world might decide to deal with oxygen toxicity by immediately locking up any liberated oxygen into other compounds, rather than just letting it diffuse freely. Hal Clement's novel The Nitrogen Fix posits that this is in fact the more typical state; the alien in that book is native to a world where plants all produce nitrate, animals eat or drink it, and nothing needs to breathe, and only contacted Earth after an apocalyptic disaster converted all of the oxygen in our atmosphere into nitrate, leading to the near-extinction of pre-existing complex life; until then, the aliens didn't consider Earth to show any obvious chemical signatures of advanced life! And nitrate does seem like the most likely form for oxygen to be bound in, simply because nitrogen, like oxygen, is extremely common in the environment and in biomolecules. Manganese, sulfur, and phosphorus could be used as well, but when those run out in the environment, there will always be more nitrogen.
Of course, if you happen to have a lot of sulfur in the environment, then photosynthesizers may just stick with hydrogen sulfide as their hydrogen source indefinitely, producing elemental sulfur as a byproduct, which animals would have to eat. This would have the side effect of steadily converting CO2 into carbonyl sulfide (COS) as the hydrogens from hydrogen sulfide are transferred into oxygen from CO2 during photosynthesis, producing excess water, and then carbohydrates are oxidized by sulfur to produce H2S and COS instead of regenerating CO2. Plants would then have to adapt to using COS as their main inorganic carbon source rather than CO2 in order to close the cycle.
On a sufficiently hot would, animals could breathe the sulfur, but that is getting into even more extreme speculative alien biochemistry. Hal Clement wrote another novel, Iceworld, about sulfur-breathing aliens whose equivalent of water is molten copper chloride!
I see a major problem: oxygen appears in a lot of organic molecules which are interesting for life, like carbohydrates, proteins, lipids and so on. This thanks to its 2 valence electrons, allowing it to be used both in between a molecule or at its end, by binding either with two different atoms or with a single one.
Chlorine, on the other hand, has a single valence electron, meaning that it can bind only with a single atom, thus necessarily at the end of an atomic chain.
This is why some alternative oxidative paths use sulfur.
You can still try to have an hybrid chemistry using both chlorine and oxygen, but you would need an efficient way to prevent competition between the two species when it comes to chemical reactions.
Other elements have their quirks.
You can use chlorine, but it is very prone to free radical chemistry - unwanted cyclic reactions that go on and on.
You can use fluorine but except as the ion it is very prone to stick on carbon "like glue" and go nowhere. PFAS compounds, "forever pollution". Very tough to work with biochemically.
You can use bromine or iodine, but there is almost nowhere they would plausibly be common.
You can use nitrogen, but it pairs up into nitrogen gas in preference to any other state. Nitrates want to be TNT or ANFO bombs. You don't want an exploding planet (probably ... though it always does wow the tourists). And we do use it already in our planet's biochemistry anyway.
You can use sulfur, but it's not a very strong oxidizing agent; also, we use it in our biochemistry at a fundamental level already.
Your idea of perchlorates is one of the best options (oxygen and chlorine). AND they are actually present on Mars, so we know it's possible without life. Unless there's life on Mars, that is...
Sodium metal could be your carbohydrate equivalent
Photosynthesis on Earth uses H2O and CO2 and energy. Modern plants store light energy as chemical energy. Plants strip the hydrogen from the H2O and store it on the CO2 forming carbohydrate. The oxygen is released. Later the plants (or heterotrophs like us) reclaim that chemical energy by grabbing some of the O2 it let loose and combining it back, regenerating the H2O and CO2 and releasing the energy into some chemistry.
Let us imagine your plants do electrolysis of NaCl aka salt. Radiant energy is used to produce elemental sodium and chlorine. Energy is stored as sodium metal in the plant - maybe stowed in some greasy hydrocarbons. Chlorine gas is released. The world has an atmosphere full of chlorine gas produced by photosynthesis just as ours has a lot of oxygen gas. When the plant wants to reclaim the energy or something eats the plants, the sodium metal stores are reacted with ambient chlorine gas to regenerate salt.
Other salts could be treated similarly - for example magnesium or lithium chloride could also be electrolyzed to the metal and chlorine gas. I could imagine plants might evolve an end run around herbivores by switching their metabolism to produce a metal that the herbivores could not use.
Can you builders grok a plant whose tissues are silvery crystals with a greasy sheen, seen dimly through the yellow haze?