Convergence of infinite products flaw in this derivation of Euler product formula? I am trying to write a derivation of the Euler product formula in a way that is accessible to younger students and those not mathematically trained at university.
Because of this I am starting from the simplest starting point that I can, and use the simplest possible steps in the derivation.
I arrive at the following which I know is wrong as it is missing the exponent $s>1$ to ensure convergence.
$$ \prod_{p}\frac{1}{(1-\frac{1}{p})}=\sum_{n}\frac{1}{n} $$
My question is to ask where I am introducing the error in the following simple derivation.

Step 1
Start with a familiar series, valid for $|x| < 1$.
$$ \frac{1}{(1-x)}=1+x+x^{2}+x^{3}+\ldots $$
We're interested in primes, and might be tempted to set $x$ to a prime $p$, but we can't because $|x|$ needs to be $<1$. Let's try $\frac{1}{p}$ which is always $<1$.
$$ \frac{1}{(1-\frac{1}{p})}=1+\frac{1}{p}+\frac{1}{p^{2}}+\frac{1}{p^{3}}+\ldots $$
This series converges to a finite value.

Step 2
Let's now pick two different primes $p_1$ and $p_2$, and multiply the analogous series for each.
$$ \frac{1}{(1-\frac{1}{p_{1}})}\cdot\frac{1}{(1-\frac{1}{p_{2}})}=\left(1+\frac{1}{p_{1}}+\frac{1}{p_{1}^{2}}+\ldots\right)\cdot\left(1+\frac{1}{p_{2}}+\frac{1}{p_{2}^{2}}+\ldots\right) $$
I don't think there is a problem here.
We are multiplying two infinite series, each one known to converge to a finite value. Am I wrong?

Step 3
Now we extend from two primes, $p_1$ and $p_2$, to all primes $p_i$.
$$ \prod_{p_{i}}\frac{1}{(1-\frac{1}{p_{i}})}=\prod_{p_{i}}\left(1+\frac{1}{p_{i}}+\frac{1}{p_{i}^{2}}+\ldots\right) $$
I think this is the flaw in my derivation. We have an infinite product of finite values.
Each factor $\frac{1}{(1-\frac{1}{p_{i}})}$ is $>1$ so the infinite product looks like it might not converge.
However each factor tends to $\rightarrow 1$ as $i \rightarrow \infty$. This suggests the infinite product is ok. Am I wrong?

Step 4
If we multiply out those brackets, each of the form $\left(1+\frac{1}{p_{i}}+\frac{1}{p_{i}^{2}}+\ldots\right)$, we will obtain terms which are all combinations of primes, in all the combinations of powers for each prime.
$$ \prod_{p_{i}}\left(1+\frac{1}{p_{i}}+\frac{1}{p_{i}^{2}}+\ldots\right) = 1 + \frac{1}{p_1} + \frac{1}{p_2} + \ldots + \frac{1}{p_1 p_2} + \frac{1}{p_1 p_3} + \ldots + \frac{1}{p_1^2} + \frac{1}{p_2^2} + \ldots  $$
Importantly, each combination occurs only once.

Step 5
The fundamental theorem of arithmetic tells us that each integer can be written as a unique product of primes. This means that each integer is represented in the terms we arrived at in the previous step.
Because each combination of primes occurs only once, each integer is represented only once.
That leads us to the Euler product formula.
$$ \boxed{\prod_{p}\frac{1}{(1-\frac{1}{p})}=\sum_{n}\frac{1}{n}} $$

Discussion
If my suspicion is correct that the error is in the infinite product because it doesn't converge, how does changing $p$ for $p^s$ for $s>1$ help?
 A: Your intuition is right that there is a flaw in step 3. You propose that any infinite product in which the terms tend to $1$ must converge; but this is false. The easiest example is the telescoping product
$$
\prod_{j=1}^J \bigg( \frac{j+1}j \bigg) = J+1,
$$
which show that $\prod_{j=1}^\infty \frac{j+1}j$ diverges to $\infty$. More generally, the convergence of the product $\prod_j (1+x_j)$ is by definition equivalent to the convergence of its logarithm $\sum_j \log(1+x_j)$, and in many circumstances this is further equivalent to the convergence of the logarithm's linear approximation $\sum_j x_j$; the example above is the case $x_j = \frac1j$. This is where we need the assumption $s>1$.
There is also a flaw (a very common one, in my experience) in step 4. You are correct that each of the terms on the right-hand side appears when we expand the left-hand side. However, there are literally uncountably many other terms as well. What about, for example, the term in the expansion where we select $\frac1{p_i^1}$ from every factor? What happens to a term like $\frac1{p_1p_2\cdots}$? And all the others where infinitely many of the factors don't equal $1$? In my opinion, it's not very easy to repair this flaw without starting over and using a more rigorous real-analysis proof.
A: Step 3 is where a "big leap" first occurs in the logic.  Putting the variable $s$ back into the exponent, it is an interesting issue that the geometric series expansion
$$
\frac{1}{1-1/p^s} = 1 + \frac{1}{p^s} + \frac{1}{p^{2s}} + \frac{1}{p^{3s}} + \cdots = \sum_{k \geq 0} \frac{1}{p^{ks}}
$$
is completely valid when $s > 0$ (or ${\rm Re}(s) > 0$ if you want to use complex variables) and also when multiplying together finitely many of these equations, but multiplying such equations together over all $p$ is invalid when $0 < s \leq 1$.
It's hard to pin down an intuitive reason why something goes wrong in the passage from the finite to the infinite when $0 < s \leq 1$ but not when  $s > 1$. You can't say "well, after some definite finite number of steps there's a problem".  The issue is entirely about what's going on with the full infinite product. It's sort of like the number $\pi = 3.1415926535\ldots$ being irrational but it is a limit of truncated decimals $3$, $3.1$, $3.14$, and so on and at each finite stage the number is rational but the limit is not. There is no definite point at which the terms stop being rational.  That property is true at the limit but not at an earlier step.  Or an infinite series of continuous functions can be discontinuous (Fourier series). Limits are subtle.
The only mathematically acceptable way to "explain" why we need $s > 1$ is to bring in a serious theorem that justifies when infinite products can be expanded and rearranged arbitrarily to get a legal infinite series. Here is such a theorem.
Theorem. Let $\{z_n\}$ be real or complex numbers such that (i) $|z_n| \leq 1 - \varepsilon$ for
some positive $\varepsilon$ (which is independent of $n$)
and (ii) $\sum |z_n|$ converges.
a$)$ The infinite product
$\prod_{n \geq 1} \frac{1}{1-z_n} := \lim_{N \rightarrow \infty}
\prod_{n=1}^{N} \frac{1}{1-z_n}$ converges to a nonzero number.
b$)$ Every rearrangement of factors of the product converges to the same value.
c$)$ The product $\prod_{n \geq 1} \frac{1}{1-z_n} = 
\prod_{n \geq 1} (1 + z_n + z_n^2 + \dots)$ has a series expansion
by collecting terms in the expected manner:
$$
\prod_{n \geq 1} \frac{1}{1 - z_n} = 
1 + \sum_{r \geq 1}\sum_{\substack{k_1,\dots,k_r \geq 1 \\ 1 < i_1 < \dots < i_r}}
z_{i_1}^{k_1}\cdots z_{i_r}^{k_r}, 
$$
and this series is absolutely convergent.
Applying this with $z_n = 1/p_n^s$, where $p_n$ is the $n$th prime and $s > 0$, what we need in this theorem to justify the expansion of the Euler product into the Dirichlet series for the zeta-function is (i) $1/p_n^s \leq 1-\varepsilon$ for all $n$ and (ii) $\sum_{n \geq 1} 1/p_n^s < \infty$. There is no issue with the first condition regardless of the value of $s$, since $1/p_n^s \leq 1/2^s < 1$ for each $s > 0$: we can use $1-\varepsilon = 1/2^s$. But for the second condition we need $\sum_{n \geq 1} 1/p_n^s < \infty$. That is true for $s > 1$ but not for $0 < s \leq 1$, and this is how the theorem uses $s > 1$. But that is not intuitive and I do not think such convergence criteria from analysis are  intuitive for inexperienced students.  It is the actual nuts and bolts of the proof of the theorem that shows how the hypotheses lead to the conclusion here.
My advice is to point out there is a subtlety at $s = 1$, which makes it plausible that for $s < 1$ things are also bad (because $1/p^s > 1/p$ when $0 < s < 1$) and then just say mathematicians can justify that the the result of informal handwavy calculations is okay for $s > 1$.  Make some reference to the integral test if the students have seen that already: $\int_1^\infty dx/x^s$ is convergent for $s > 1$ but not for $0 < s \leq 1$ even though $\int_1^b dx/x^s$ is meaningful for all $s > 0$ when $b$ is finite.
A: You are correct that step 3 is a problem.  (This is not to say that steps >3 are not also problems.)
You suggested that if the factors tend to 1 then it will be okay, but that is not valid.  For instance,
$$
\prod e^{1/n}=e^{\sum 1/n}=e^\infty=\infty
$$
A: The other answers have mentioned that your product does not converge and shown why that is. However, I don't think that ruins the value of this approach, and my answer here is to complement those by suggesting how to make it work. What I'd suggest is that, ultimately, you're going to need to get $s$ into the product somehow, because it is material to the value of the sum, so what we should instead do is actually use the fact that the simple product
$$\prod_{n=1}^{\infty} \frac{1}{1 - \frac{1}{p_n}}$$
fails, after suitable demonstration it does fail, as a pivoting point in the derivation - after all, it seems what you're asking is to "explore" for the formula, and in exploration of any type you may have to reverse course. Hence, we should then step back and figure how to introduce $s$ in somehow. And I'd say that, since we're talking $s$-th powers in our target sum, we should put that on $p_n$, i.e. consider
$$\prod_{n=1}^{\infty} \frac{1}{1 - \frac{1}{p_n^s}}$$
. And then when you do that, I would suggest you can avoid the whole business about rearranging infinite sums of terms by remembering that there's a limit definition of infinite products and sums, and stepping back to that:
$$\prod_{n=1}^{\infty} \frac{1}{1 - \frac{1}{p_n^s}} = \lim_{n_\mathrm{max} \rightarrow \infty} \prod_{n=1}^{n_\mathrm{max}} \frac{1}{1 - \frac{1}{p_n^s}}$$
(and we might even convert this to a double limit) and then convert the right-hand product to
$$\prod_{n=1}^{\infty} \frac{1}{1 - \frac{1}{p_n^s}} = \lim_{n_\mathrm{max} \rightarrow \infty} \prod_{n=1}^{n_\mathrm{max}} \left(\sum_{k=0}^{\infty} \frac{1}{p_n^{sk}}\right)$$
where now we don't have to worry about producting an infinite number of factors now. So we can now expand the sums out, and they will have terms of the form
$$\frac{1}{\underbrace{p_{a_1}^s p_{a_2}^s \cdots p_{a_n}^s}}$$
where every combination of positive integers $a_j$ of the given length $n$, $n = 1, 2, \cdots, n_\mathrm{max}$ will contribute to the sum. Because of unique factorization, we have that the denominators will thus occur exactly once and be a subset of
$$\{1^s, 2^s, 3^s, \cdots\}$$
and we can then argue that, since increasing $n_\mathrm{max}$ means the factorizations get longer, this subset must approach the full set, and so once we pass to the limit, the desired summation identity obtains.
A: I'll give another treatment of the problem in step 4 - plenty of other answers cover step 3 but there's a relatively accessible way of explaining why step 4 is invalid that may be useful for the kind of teaching you're doing.
It comes down to what we mean by an infinite sum. We have to remember that a sum of infinite terms is defined as the limit of the sequence of all its partial sums.
Let's look at that infinite product you defined in step 4:
$$ \prod_{p_{i}}\left(1+\frac{1}{p_{i}}+\frac{1}{p_{i}^{2}}+\ldots\right) = 1 + \frac{1}{p_1} + \frac{1}{p_2} + \ldots + \frac{1}{p_1 p_2} + \frac{1}{p_1 p_3} + \ldots + \frac{1}{p_1^2} + \frac{1}{p_2^2} + \ldots  $$
The right-hand side is expressed as an infinite sum, but as I've mentioned, what that actually means is that it's the limit of the sequence:
$$ 1, 1 + \frac{1}{p_1}, 1 + \frac{1}{p_1} + \frac{1}{p_2}, \ldots  $$
The problem is that for any natural number i, the ith term of this sequence is only affected by the terms up to $$ \frac{1}{p_i} $$ - the later terms in the sum expressed at the top never appear. This means that when we take the limit, only those initial terms appear, and it's actually just giving us:
$$ \sum \frac{1}{p_i} $$
In general, reordering infinite sums like this often introduces problems: you can't put any infinite set of terms first, as that makes any terms that would appear 'after' them no longer actually appear in the sequence whose limit we find to calculate the sum. That's not to say this is the only way such reorderings can cause problems, either, but examples of such are further from the scope of this question.
