let $\chi_1, \dots, \chi_n$ be the irreducible characters and let $\chi$ be the character of the regular representation. We want to compute $\sum_{i=1}^n \chi_i(1)$ and show that this is equal to $\frac{1}{|G|}\sum_{g \in G}\chi(g^2)$ (that's the number of elements such that $g^2=1$, as we explicitly know what $\chi$ looks like.)
Now write $\chi=\sum_{i=1}^n \chi_i(1)\chi_i$ (this follows from the decomosition of the regular representation), then we have $\frac{1}{|G|}\sum_{g \in G} \chi(g^2)=\frac{1}{|G|} \sum_{g \in G} \sum_{i=1}^n \chi_i(1)\chi_i(g^2)$ interchange the sums, this is equal…
Now write $\chi=\sum_{i=1}^n \chi_i(1)\chi_i$ (this follows from the decomosition of the regular representation), then we have $\frac{1}{|G|}\sum_{g \in G} \chi(g^2)=\frac{1}{|G|} \sum_{g \in G} \sum_{i=1}^n \chi_i(1)\chi_i(g^2)$ interchange the sums, this is equal…