The first reason I want to clarify is that, the resistance being the real part of (complex) impedance and the (magnitude of the) reactance being the imaginary part of the (complex) impedance, is a fact, not a convention/rule as some answers may suggest. Before answer the why of your question, I'll try to convince you what I said is true. If you already know all of this, just head to the last four paragraphs of the answer.
I'll assume you're familiar with resistors, inductors and capacitors, sinusoids, and phasors.
—In a resistor of constant resistance, inductor of constant inductance, and capacitor of constant capacitance, it can be mathematically proven or physically demonstrated that instantaneous voltage \$v(t)\$ - instantaneous current \$i(t)\$ relationship is given by:
\$v(t) = R \, i(t) \quad \text{(resistor)} \tag 1\$
\$v(t) = L \, \dfrac{\mathrm di(t)}{\mathrm dt} \quad \text{(inductor)} \tag 2\$
\$i(t) = C \, \dfrac{\mathrm dv(t)}{\mathrm dt} \quad \text{(capacitor)} \tag 3\$
When those devices are driven by sinusoidal current or voltage, the resulting voltage or current is also sinusoidal, of same fundamental frequency, and with zero DC offset.
—Given a sinusoidal signal \$x(t) = X_\text{m} \cos{(\omega t + \phi)}\$, its phasor is defined as \$\tilde X = X_\text{m} e^{j \phi}\$. Notice that the defining equation that relates a sinusoidal signal to its phasor is \$x(t) = \Re [\tilde X e^{j \omega t}]\$. With this fact, it can be mathematically proven (as I did in this Quora answer) that the phasor voltage \$\tilde V\$ - phasor current \$\tilde I\$ relationship of the three previous devices, provided they're operating with sinusoidal voltages and currents of same frequency, are:
\$\tilde{V} = R \tilde{I} \quad \text{(resistor)} \tag 4\$
\$\tilde{V} = j \omega L \tilde{I} \quad \text{(inductor)} \tag 5\$
\$\tilde{I} = j \omega C \tilde{V} \quad \text{(capacitor)} \tag 6\$
The (complex) impedance \${\hat Z}\$ of a two-terminal passive device/circuit is defined as the ratio of the phasor voltage \$\tilde{V}\$ across the device to the phasor current \$\tilde{I}\$ through the device:
\${\hat Z} := \dfrac{\tilde{V}}{\tilde{I}} \tag 7\$
Thus, from equations (4) to (6) we easily obtain the (complex) impedance of a resistor, inductor and capacitor, as follows (I explained this in more details in this Quora answer):
\${\hat Z} = R \quad \text{(resistor)} \tag 8\$
\${\hat Z} = j \omega L \quad \text{(inductor)} \tag 9\$
\${\hat Z} = \dfrac{1}{j \omega C} = -j \dfrac{1}{\omega C} \quad \text{(capacitor)} \tag {10}\$
—It can be mathematically proven (as I did in this Quora answer; do not read the last section where I talk about the sign of reactance) that the maximum voltage \$V_\text{m}\$ - maximum current \$I_\text{m}\$ relationship of the inductor and capacitor, provided they're operating with sinusoidal voltages and currents of same frequency, are:
\$V_\text{m} = \omega L I_\text{m} \quad \text{(inductor)} \tag {11}\$
\$I_\text{m} = \omega C V_\text{m} \quad \text{(capacitor)} \tag {12}\$
The magnitude of the reactance \$X\$ of an inductor or capacitor operating in sinusoidal steady-state is defined as the ratio of the amplitude/maximum value/peak value \$V_\text{m}\$ of the instantaneous voltage across the device to the amplitude/maximum value/peak value \$I_\text{m}\$ of the instantaneous current through the device:
\$|X| := \dfrac{V_\text{m}}{I_\text{m}} \tag {13}\$
Thus, from equations (11) and (12) we easily obtain the magnitude of the reactance of an inductor and capacitor, as follows:
\$|X| = \omega L \quad \text{(inductor)} \tag {14}\$
\$|X| = \dfrac{1}{\omega C} \quad \text{(capacitor)} \tag {15}\$
—Substituting equations (14) and (15) into (9) and (10), respectively, we get:
\${\hat Z} = j |X| \quad \text{(inductor)} \tag 9\$
\${\hat Z} = -j |X| \quad \text{(capacitor)} \tag {10}\$
Aha! This shows/proves that the reactance is the imaginary part of impedance. This is not a convention. Throughout the derivation we didn't make an arbitrary rule, except for defining (complex) impedance as the ratio of phasor voltage to phasor current, but that's to make it analogous to resistance and thus make the equation look like Ohm's law.
Now that I've hopefully convinced you that \$X\$ being the imaginary part of \$\hat Z\$ is not a convention/rule but a proof/theorem, let's address the why of your question.
In brief, it's because of the following.
It can be mathematically proven and physically demonstrated that, in sinusoidal steady-state, in a resistor the instantaneous voltage is in phase with the instantaneous current, in an inductor the instantaneous voltage leads by 90° the instantaneous current, and in a capacitor the instantaneous current leads the instantaneous voltage by 90°.
But, multiplying a complex number by the imaginary unit \$j\$ makes the complex number to be rotated 90° counterclockwise, making the new complex number lead the original complex number by 90° in the complex plane (as I proved in this and this Quora answer).
Thus, it follows that in the phasor relationship for a resistor there mustn't be a \$j\$ present (because the phasor voltage must be in phase with the phasor current), in an inductor there must be a \$j\$ multiplying the phasor current (along with \$\omega\$ and \$L\$) to produce the phasor voltage (because the phasor voltage must lead by 90° the phasor current), and in a capacitor there must be a \$j\$ multiplying the phasor voltage (along with \$\omega\$ and \$C\$) to produce the phasor current (because the phasor current must lead by 90° the phasor voltage).
Therefore, when we compute the (complex) impedance, which is defined as the ratio of phasor voltage to phasor current, we still get no \$j\$ in the resistor, a \$+j\$ in the inductor, and a \$-j\$ in the capacitor.