How did UV from the earliest stars 'alter the state of the 21 cm line' such that it shows up in CMB today?
The Intergalactic medium at the relevant redshift is made of neutral hydrogen. What we can measure is the brightness temperature (the temperature that the IGM would have if it emitted as a blackbody) relative to the CMB. This quantity depends crucially on the following expression:

$\frac{T_S - T_{CMB}}{T_S}$

where $T_S$ is called spin temperature.

The spin temperature is just a measure of the ratio between the number of hydrogen atoms in the first excited hyperfine state (spin parallel) and ground state (spin antiparallel).
It turns out that the spin temperature can be modified in three ways: one of them is Lyman resonant scattering (the other two are collisional coupling and scattering of CMB photons). 
Using atomic physics it's not difficult to see that $T_S$ is a weighted mean of the temperature of the CMB and gas temperature.

UV photons can change the spin temperature because a hydrogen atom in the lowest state, n=1 (if you are familiar with chemistry, a s state) with antiparallel spins, can absorb an UV photon and jump in a p (n=2) state, and then fall again in a s state but with parallel spins.
This mechanism is known as Wouthuysen–Field coupling.

Before the emission takes place, the gas is at the same temperature of the CMB and both are equal to spin temperature, so the relative brightness temperature is zero.
When Lyman alpha emission begins the spin temperature decreases resulting in the observed absorption peak. 
At some point the peak stops because the first stars emit X-rays and the gas becomes hotter than the background radiation.