How was the diatomic nature of many common gaseous elements originally determined?
Here I'll only provide the reasoning for $\ce{O2}$ and $\ce{H2}$ diatomic structure, I think similar reasoning was to deduce that of $\ce{Cl2}$.
The divalency of oxygen, shown by Avogadro's hypothesis.
It is known that two volumes of hydrogen gas and one volume of oxygen gas combine to form water. From Avogadro's hypothesis (equal volumes of gas contain equal numbers of molecules) it can be concluded that water must have two atoms of hydrogen and one atom of oxygen (or conceivably some multiple). Hence, oxygen is divalent (valence of 2) while hydrogen has a valence of 1:
$$\ce{2H + O \to H2O}$$
This would indicate that $\frac12$ gram of hydrogen atoms reacted with 8 grams of oxygen atoms. Since the
atomic weight of hydrogen was defined as $H = 1$, then the respective atomic weights of hydrogen and oxygen would be $H = 1$ and $O = 16$ (the values accepted today).
The diatomic nature of hydrogen and oxygen, as shown by Avogadro's hypothesis.
It is observed that when two volumes of hydrogen gas and one volume of oxygen gas combine, two volumes of water gas are formed. If hydrogen and oxygen were monatomic (as shown in the equation above), then only one volume of water would be formed. The only explanation is that hydrogen and oxygen are diatomic:
$$\ce{2H2 + O2 \to 2H2O}.$$
(Copied almost verbatim from this page)