$65537$ is not always coprime to $\varphi(N)$ in RSA1. But it often is, because:
- It often2 is chosen $e=F_4=2^{(2^4)}+1=65537$ in RSA, and then the requirement3 that $e$ is coprime to $\varphi(N)$ translates to $65537$ coprime to $\varphi(N)$. Because $e=65537$ is prime, this can be checked as $p\bmod e\ne1$ and $q\bmod e\ne1$, or the primes $p$ and $q$ generated to match these conditions.
- Even when it is chosen another other $e$ : because $65537$ is a not-too-small-prime, when we choose a large prime $p$, it's unlikely that $p\bmod65537=1$ (probability $1/65536$). Same for $q$. Thus the probability that $65537$ is not coprime to $\varphi(N)=(p-1)(q-1)$ is next to $1/32768$ (or $0$ if the chosen $e$ is a multiple of $65537$).
1 Small counterexample: $p=917519=14\times65537+1$, $q=820681$, $N=p\,q=752990410439$, $\varphi(N)=(p-1)(q-1)=752988672240$, $\gcd(\varphi(N),65537)=65537$, $e=17$, $d=177173805233$ or $d=15819089753$.
2 The reasons of this common choice are many (and debated), including that
- The form $e=2^k+1$ give the fastest ratio of (time to raise to the odd power $e$ modulo $N$) over ($\log e$): we square $k$ times, then multiply by the original number.
- Prime $e$ slightly simplify the choice of factors of $N$ such that $e$ is coprime with $\varphi(N)$, and the above form of $e$ is prime for $e=F_i=2^{(2^i)}+1$ with $i\in\{0,1,2,3,4\}$. Notice that to validate that a prime $p$ is suitable w.r.t. a prime $e$, it's enough to check that $p\bmod e\ne1$, when in the general case of a composite $e$ we need to check that $\gcd(p-1,e)=1$.
- Larger $e$ protect to some degree against some attacks on obsolete, generally insecure RSA encryption practices including RSAES-PKCS1-v1_5
- $e=F_4=2^{(2^4)}+1=65537$ has (thus) been recommended as the minimum value by several security authorities and standards.
3 Without this requirement, textbook RSA would often encipher two plaintexts into the same ciphertext, making decryption impossible.