How do they measure the CMB temperature? Aren't they just some radiation?
Yes! The CMB very accurately follows to Planck spectrum of a black body at a specific temperature. That temperature is measured by the frquency of the peak of the spectrum as shown here.
What is the black body here? Is it the whole universe? How does it happen that CMB is a perfect black body spectrum?
The whole universe was originally filled with hot ionised hydrogen and helium that were the products of nucleosynthesis in the BB. The energy for the radiation is thought to have come from the epoch of matter-antimater annihilation where (108 + 1) matter particles annihilated 108 anti-matter particles leaving ~108 photons per atomic particle in the present universe.
That radiation was bounced around the very early and opaque universe until the plasma termperature fell to ~ 30000K when the protons and electrons associated to form neutral hydrogen atoms, then the universe became transparent.
We see that 'Surface of Last Scattering' all around us and now red-shifted by z ~ 1100 as the CMB.
The plasma and subsequent gas was remarkably homogeneous and isotropic and therefore its radiation follows a Planck black-body spectrum very closely.
There are anisotropies, of course, but they are another story.
Separate names with a comma.