Let’s construct the same set $S_d=\{x: 1\leq x\leq n$ and $gcd(x,n)=d\}$ in a different way and find out. This way, I believe, one can feel all the details. Although one might argue that some of these facts needn't be proved as they are already clear in their definition. But as I've seen, most people can't agree, at first, how these are so obvious.

Take $A_d=\{x: 1\leq x\leq \frac{n}{d}$ and $ gcd(x,\frac{n}{d})=1\}$. Then of course, $\mid A_d\mid =\varphi(\frac{n}{d})$ as this is indeed the definition of $\varphi$. Now consider the set $B_d=\{x: x=d.y$ where $ y\in A_d\}$. Then again, of course, $\mid B_d\mid =\varphi(\frac{n}{d})$. For any $x \in B_d$, both $gcd(x,n)=d$ and $1\leq x\leq n$ are true. So, $B_d \subseteq S_d$. If there was an $m \in S_d$ but $m \notin B_d$, then that would mean, $\frac{m}{d}∉A_d$. But that can’t be possible as $\frac {m}{d}(=x)$ satisfies $1\leq x\leq \frac {n}{d}$ and $gcd(x,\frac {n}{d})=1$, both the conditions to be in $A_d$. Hence, $B_d=S_d \Longrightarrow\mid S_d\mid =\mid B_d\mid =\varphi(\frac {n}{d})$. Now consider the set $S= \bigcup{S_d}$ . This set must include all integers from $1$ to $n$. For if it didn’t, then there would exist an $x$ such that $1\leq x\leq n$ but $gcd(x,n)=k$ which is not one of the $d$s we considered. But that is not possible. So it follows that, $\mid S\mid =\sum{\mid S_d \mid } =\sum{\varphi(\frac{n}{d})}= \sum{\varphi(d)}=n$.