If you are confused about why the electrons don't 'disappear' yet somehow transfer energy, think of this analogy: When I pour water down over a water mill, energy is being transferred from the water flowing to the water wheel spinning, yet at the end of the day no water 'disappears' in this process. The energy is in the fact that I can get that water (or in the electrical case, the electrons) moving in the first place.
Perhaps a better analogy is the following:
Think of a belt being pulled around in a machine. The amount of belt (similar to our amount of electrons) as well as it's speed (and the speed of the electrons) stays the same for the entire belt - otherwise the belt would bunch up somewhere. Yet when something loads the belt - say a block is rubbing against the belt with a lot of friction - energy is being transferred from the motor that moves the belt to the block, and the block gets hot. The energy is being transferred because in order to keep the belt moving the motor needs to put effort (work) into the belt. The belt can't be 'used up' just like the electrons can't be used up because we would tear our belt (or in the case of the electrons, if they would stop inside the resistor, they would all bunch up and form a lot of charge there). So nothing is being 'lost', but instead the energy is needed to 'convince' the electrons to start moving in the first place. The faster you want them to move (= more current) means more effort (more voltage) and as a result more power.
The way the actual energy is transferred is (mainly) through collisions. In actual fact, electrons are already moving a lot in a metal, at least when that metal is at room temperature. Temperature is just a way to describe the kinetic energy of our particles (electrons, atoms, or molecules all move and vibrate). Most conductive materials have free electrons - these are electrons that do not belong to one single atom in a crystal lattice but are 'shared' between all the atoms. (there can/will also be holes in some cases, but let us pretend we only have electrons for now).
These electrons kinda just wander about, in a random way. As a result, they don't move over the long term, and they just dance around their position. Think of the analogy of dancers on a dance floor - they might all move, but in general, we don't get dancers moving from one side of the dance floor to the other, on average they all stay put. If we add energy to them, they start moving around faster. On a macroscopic scale, this speed of wandering is what we call 'heat', and more kinetic energy means the material is 'hotter'. The technical term for this moving around is 'Brownian Motion'
In the image below, on the left is the path of an electron without a current flowing through the material. The electron bounces back when it runs into the nucleus of an atom as the nucleus is positively charged (made out of neutral neutrons and positively charged protons), and the electron negatively charged. On the right, we have the same path (roughly, I've done this by hand but I think the idea is clear) but with an external electric field present (due to our voltage across the resistor). The electron will now, in addition to thermal movement, experience a drift opposite to the electric field. .
So, now that we understand all that, how does this heating thing work?
Well, every time the electron bumps into an atom, it trades some energy. Perhaps the electron now moves a bit faster after and the atom vibrates a bit less, or vice versa. This is a constant and random exchange, and since both the energy of both movements (the electron's random walking and the core of the atom vibrating) come from within the material, nothing really changes - the material does not heat up or cool down.
When we apply an electric field, things change. This electric field is external, and the electrons will constantly accelerate because of it. This is seen in the image as the curving of the electrons toward the right, no matter where the electron starts. Every collision, the electron dumps its energy into the atom it hits, giving that atom more kinetic energy. The electron then slowly accelerates due to the electric field, gaining more kinetic energy again, hits another atom, exchanging energy, etc...
In other words, as a result of this electric field we are adding more and more kinetic energy to the system, and that kinetic energy shows up as heat - our resistor is getting hotter.
But wait! How does this not break physics? We are just putting a field across a material and suddenly it heats up? Aren't we getting energy from nothing?
Not really! You see, as all of our electrons move towards the positive side of our electric field, they are moving charge in that direction. If at no point we are 'pushing' electrons back to the negative side we would get some electrons bunching up at the positive terminal, forming a negative charge there, and this would then cancel out the positive charge. Our electric field disappears.
In order to get a continuous current flow, we need to prevent this - at some point, we need to take the electrons at the positive terminal and force them back to the negative one. We can do this with a generator, where we use magnetic fields to convince them to go back.
In the case of a battery, we are not sending those same electrons back, but rather storing them at the positive side and releasing new ones at the negative terminal in a chemical reaction. Eventually, the reagents for this run out and the battery can't store any more electrons, and the field is no longer present.
This model is called the Drude model and fails to explain certain things (such as why some metals have a positive instead of negative hall coefficient, and why exactly does copper conduct so much better than iron?) but it gives a good first understanding of some of the principles at work.