What happens to matter when it is converted into energy?

Much of mass is just binding energy, so in a chemical reaction the electrons rearrange themselves and energy is released and the total mass of the molecules goes down (in an exothermic reaction, for example).

The same is true for common nuclear reactions like spontaneous fission of uranium, with the caveat that some important nuclear reactions do involve the changing of fundamental particles, e.g., beta decay:

$$ n \rightarrow p + e^- + \bar\nu_e $$

Here the mass of the RHS is less than that of LHS, so the electron and antineutrino are energetic (in the neutron rest frame). The energy comes from the difference in the neutron (936.6 MeV) and (938.3 MeV) proton masses, which is about 1.3 MeV.

That 1.3 MeV is not binding energy, rather it is the quark mass difference coming from:

$$ d \rightarrow u + e^- + \bar\nu_e $$

where the up (down) quark mass is $2.3\pm 0.7 \pm 0.5$ MeV ($4.8\pm 0.5 \pm 0.3$ MeV). Note that most of the nucleon mass is once again binding energy.

So what happens to mass when the down decays into an up? Nothing. Mass is not stuff, mass is a quadratic coupling to the Higgs boson that leaves finite energy at zero momentum:

$$ E = \sqrt{(pc)^2 + (mc^2)^2} \rightarrow_{|p=0}=mc^2$$

or in other terms free particle waves (divide by $\hbar$):

$$ \omega = \sqrt{(kc)^2 + (mc^2/\hbar)^2}\rightarrow_{|p=0}=mc^2/\hbar$$

it is just finite finite frequency at zero wavenumber.

How does it work that matter is not stuff and is just a quanta in the quantum field? While we are generally comfortable with the photon being a quanta in the electromagnetic field which can appear and disappear at will (provided at least energy and momentum are conserved), this is because we view the EM field as a fundamental object. Moreover, the photon is its own antiparticle, and is neutral, so the conservation of charge and other quantum number does not always come to mind. They are also boson, so we don't think of them as "stuff" because they can be in the same quantum state.

Well so is the quark field also fundamental, and its quanta are up and down quarks (and more), and in the case of beta decay, the $W$ boson changes the quark's flavor (and charge, and other quantum numbers) such that at rest, the initial quanta ($d$) has a stronger coupling to the Higgs than the final quanta ($u$), which we see as more mass in the initial state and hence more kinetic energy in the final state.

Of course, you may still see the quarks as "stuff" and consider the Higgs coupling as some sort of binding energy leading to mass. That's OK.

So let's look at electron-positron annihilation:

$$ e^+ + e^- \rightarrow 2\gamma $$

Here, matter (2 leptons) just disappear and turn into 2 gamma rays. The initial state really acts like stuff: they are fermions, they cannot be in the same quantum state, they have mass, they are have charge, and so on. Enough electrons make a lightning bolt: that is very real.

But the electron and positron are both quanta in the electron-field. That is it. They have opposite charge and lepton-number (electron number), so they can annihilate without violating any conservation laws. The initial state mass is just energy at zero momentum, it is not something more "real" or fundamental than the electron field itself. The rest energy is now available for the 511 KeV gamma rays, which is just 2 quanta in the EM field (and it is charge that couples the two fields).

So in summary: all matter is made from quanta in quantum fields, and the fields are the fundamental objects. Mass is just Higgs coupling. If particle and antiparticle meet, they can annihilate, in which case the mass disappears (or not, there can be massive particle in the final state).

Since things like baryon number and electron number are conserved, the basic particles they make (atoms), in the absence of antimatter, appear stable and look like "stuff". But fundamentally: they are neither.

First off, I'd like to point out, because the term comes up often, in strict usage there is no such thing as "pure energy". Energy is not a stuff, as in particles, but a number that is associated with stuff, a quantity, though that quantity can indeed be thought of as acting, given its conservation property, like a sort of intangible "stuff" that you can put some of here or there or move around in different ways. Of course, I suppose, there's some philosophical wrangling you can do there - after all, "particles" could be considered "just numbers", too, in a sense, if you just stick to a crude instrumentalist understanding. So perhaps I should say "energy is not particles", as opposed to "not a 'stuff'".

Instead of talking about "matter" turning to "energy", it is more proper to talk about mass as a form of energy, so there is no question of "conversion": mass is already an energy. What happens is we have conversion of that energy from one form to another form, and in doing so, other things have to change, and that may mean particles being rearranged or one kind of particles turn into another kind of particles.

In this case, since you talk of "pure energy" and I am well in touch with how people talk of things colloquially, I presume what you're thinking of is annihilation - such as between a particle and its antiparticle. Well, what happens there is the second kind of process: the old particles disappear and simultaneously (at least, with the usual caveat that we cannot watch quantum processes, but the maths for what we can run of the inbetween tell us that if anything there can be called the "annihilation event", "simultaneous" ain't too bad in dealing with it) new particles appear. If it's an electron and a positron, you get two photons. If it's a proton with antiproton, you get (ultimately) some photons and also neutrinos. The latter actually have some mass, but the former do not. All of them have energy, though, and the energy is conserved throughout.

What happens is that in these cases, the rest (or "mass") energy of the particles, proportional to their mass, is converted into mass and also kinetic energy of other particles. In the electron-positron case, the final energy is purely kinetic, as in a sense all of photons' energy is kinetic energy, while in the proton-antiproton case, the neutrinos have a little bit of rest mass energy, but the overwhelming majority of the energy is still kinetic in this case as well.

Einstein, in his famous but rarely-read paper "Does inertia of a body depend upon its energy content?", didn't write that matter (or, better, mass) can be converted into energy. The way he stated its result was: $$ \Delta E = \Delta m \cdot c^2, $$ i.e. in the rest frame of any system, variations of mass and variations of energy (of the system) are proportional. Such a result is unconditionally valid, and then it is applicable also to the case where the initial or final mass in $\Delta m$ is zero.

However the relation does not say anything about the mechanism or even if a process with initial or final massless state is actually possible. That is not the task of a conservation principle like this.

Actually, the first application of Einstein's relation to nuclear physics, made by Lise Meitner to estimate the energy obtained in one of the first fission processes obtained in lab, was not related to any annihilation process, but it connected the mass defect between the initial nucleus and the fission fragments to the kinetic energy of the fragments in the center of mass frame. Once again, Einstein's relation does not say anything about which fission process is possible. It is just establishing a connection between mass and energy variations.