Black body radiation was one of the first indications that electromagnetic energy is quantized.
As the temperature decreases, the peak of the black-body radiation curve moves to lower intensities and longer wavelengths. The black-body radiation graph is also compared with the classical model of Rayleigh and Jeans.
Classical electromagnetic theory which wanted the radiation emitted by a body at a specific temperature to be continuous had the so called ultraviolet catastrophe, the curve on the right. Data did not follow the classical distribution. Planck's law that required that electromagnetic radiation comes in packets called photons, (quanta of energy, E=h*nu,) i.e. that the molecules would not radiate in the continuum but from specific levels, described the data as seen in experiments. This youtube video has an experiment and some curves at 6:46.
The theoretical curve is calculated assuming a metal cavity where these quanta bounced around and then one looked at a small hole to see what comes out. A black body is a body that contains the radiation coming from the molecular energy levels and radiates it from the surface . Real bodies have constants modifying the formula, but the basic idea holds.
You are correct, quantization is crucial to describe the spectrum theoretically, and the radiation comes from displacement of electrons to higher energy levels by the kinetic energy of the lattice ( the temperature is the average kinetic energy) and then the de-excitation by the release of a photon.
The book then goes on to describe a black body as a hypothetical object that can absorb and emit at all wavelengths. I understand that this is only a hypothetical object, but how does that even make sense if electrons can only exist at certain energy levels?
A mole of matter has ~10^23 atoms/molecules. In a lattice this is still an enormous number of coupled particles, each with vibrational and rotational levels that contribute to the temperature by their kinetic energy. Each individual transition is quantized, the kick a molecule gets from the lattice and an electron goes to a higher energy level, and then decays back , all are quantized at an individual electron level. The statement "can absorb and emit at all wavelengths" covers this great multiplicity of energy levels and molecules, almost a continuum because of the great number of photons from a great number of levels . If it could do that classically ( as the classical black body had the same supposition) it would give the discrepancy with the data , the ultraviolet catastrophy.
Furthermore, the book immediately goes on to describe things such as the Stefan-Boltzmann law and Wien's law and all kinds of graphs of how temperature and intensity and wavelength of a black body relate to each other. But if a black body is theoretical, how do we even know these relations?
The black body theoretical formula is validated by experiments. The same is true by all the further formulae which use as basis the black body radiation, they are validated by experimental data. It is the way physics progresses. Theoretical models are proposed, are checked against the data and if in agreement, the model is validated and is useful for applications. The relations are derived by using physics relations/equations as applied to the problem. They are then checked against the data for validation. All these laws and formulae have been checked against data successfully and that is why they are used in the appropriate situations.