First, let \(\alpha \in S_n\) be written as a product of transpositions in two ways:
\begin{equation*}
\tau_1 \tau_2 \dots \tau_s = \alpha = \mu_1 \mu_2 \dots \mu_t\text{.}
\end{equation*}
Then we have
\begin{equation*}
e = \alpha\alpha^{-1}=\tau_1 \tau_2 \dots \tau_s \mu_t \mu_{t-1}\dots \mu_1\text{,}
\end{equation*}
so \(e\) can be written as a product of \(s+t\) transpositions. So it suffices to show that \(s+t\) must be even; then \(s\) and \(t\) must have the same parity.
Let us now induct on the number of transpositions in a decomposition of the identity. First, the identity can be written as a product of zero transpositions (or if you like it is clear that no single transposition is the identity and we can write the identity as a product \(e=(ab)(ab)\)) so our base case is done. Now suppose that any decomposition of the identity into \(n\) transpositions has \(n\) even. Let
\begin{equation}
e=\tau_1\tau_2\dots\tau_s\tag{1}
\end{equation}
for some \(s\gt n\text{.}\) We want to show that we can reduce the number of transpositions to apply our inductive hypothesis.
To do this, write \(\tau_1=(a\;b)\text{.}\) We must have an \(a\) in some later \(\tau_i\text{,}\) or else the RHS of (1) sends \(a\) to \(b\) (as this is the final swap in the product) which is not the identity. Since also \((a_i\; b_i)=(b_i\; a_i)\text{,}\) we have \(\tau_i=(a\; c)\) for some smallest \(i\gt 1\text{.}\) Now we want to pull this transposition to the left in the product. We can freely commute it with any transposition not involving \(a\) or \(c\text{.}\) When we do reach such a transposition, we have to be more careful. Otherwise, we can use the relation (for three distinct numbers \(a,c,d\))
\begin{equation*}
(c\;d)(a\;c)=(a\;d\;c)=(a\;d)(c\;d)
\end{equation*}
to rewrite any product of transpositions where the right one moves \(a\) and the left one does not as a product with the same number of transpositions but with the left one moving \(a\) and the right one not. By applying these two cases, we can get to the form
\begin{equation*}
e=(a\; b)(a\;b')\tau_3 \dots \tau_s
\end{equation*}
(note that our two rules for moving \((a\; c)\) show that the other permutations \(\tau_j\) do not change when we do this).
At this point, there are two possibilities. If \(b=b'\text{,}\) then we have the product \((ab)(ab)\) starting our RHS and so we may cancel these factors and by the inductive hypothesis the remaining product of \(s-2\) transpositions has an even number of transpositions and so \(s\) is even. Otherwise, we can use the similar relation for distinct numbers \(a,b,b'\)
\begin{equation*}
(a\;b)(a\;b')=(a\;b'\;b)=(a\;b')(b\;b')
\end{equation*}
to write
\begin{equation*}
e=(a\;b)(b\; b')\tau_3\dots \tau_s\text{.}
\end{equation*}
This new decomposition has one fewer transposition involving
\(a\) than previous. So we can repeat the same argument and at each step either we reduce the number of transpositions by two and can apply our inductive step or we can reduce the number of transpositions involving
\(a\text{.}\) Because there are at most
\(s\) transpositions involving
\(a\text{,}\) this must eventually terminate with reducing the number of transpositions by two. So by induction the identity can only be written as a product of an even number of transpositions. See
this nice YouTube video for a visual explanation of this argument.