Euler showed that an odd prime is the sum of two squares if and only if it is congruent to 1 (mod 4). Another result shows that the product of two numbers that can be expressed as a sum of two squares is itself a sum of two squares; that is, the set of such numbers is closed under multiplication. Combining these, a positive integer is expressible as a sum of two squares if an only if all of its prime factors that are congruent to 3 (mod 4) have even exponent.
EDIT: Since the numbers being squared are restricted to distinct primes, possibly the above isn't part of the proof. I forgot that restriction momentarily.