I don't understand why the resistor would have have all the voltage
and why wouldn't the capacitor have the voltage. Is this because the
capacitor is being charged 'through the resistor'? And what does this
mean?
The short answer is the voltage across an ideal capacitor cannot change instantaneously, i.e., in zero time. It therefore looks like a short-circuit (zero voltage) when the switch is first closed. That in turn means all the voltage must appear across the resistor immediately after closing the switch, per Kirchhoff's voltage law.
To fully understand, you need to consider the basic relationship between current and voltage for an ideal capacitor, which is
$$i(t)=C\frac{dv(t)}{dt}$$
or
$$v(t)=\frac{1}{C}\int i(t)dt$$
The second equation tells you that the voltage across an ideal capacitor cannot change in zero time, i.e., $v_{C}(t)$ = 0 for $dt=0$. It takes time to deliver charge to the capacitor plates so that a voltage appears across the plates. So the instant after the switch closes, the ideal capacitor looks like a short circuit. That means all the voltage drop is across the resistor the instant after the switch closes.
Then, as net charge builds up on the capacitor plates the current goes down, eventually becoming zero. From the first equation if the current is zero, the voltage across the capacitor is no longer changing in time, i.e., it is fully charged and equals the voltage of the source.
The applicable DC transient equations after closing a switch on a series RC circuit where there is no net charge initially on the capacitor (no initial Voltage) are
$$v_{C}(t)=V(1-e\large^{-\frac{t}{RC}})$$
$$i(t)=\frac{V}{R} {e\large^{-\frac{t}{RC}}}$$
$$v_{r}(t)=i(t)R=V{e\large^{-\frac{t}{RC}}}$$
The first equation shows that at time $t=0$, the instant after closing the switch, the voltage across the capacitor is zero. The second equation shows that at $t=0$ the current is $V/R$. Finally, the third equation shows that the voltage across the resistor is $V$ at $t=0$.
After a long time ($t$ = infinity), the voltage across the capacitor is $V$ (first equation), current in the circuit is zero (second equation), and the voltage across the resistor is zero (third equation).
Hope this helps.