Okay, so you may have lived in a house, and you may have noticed that as you live in a house, things tend to get dusty. There is just a dust on everything. Until you clean it off.
You may have also noticed that the dust is in greater density in certain places than others. So there might be more dust on the floor than on a high shelf. There is still dust on the high shelf, but something about gravity doesn't allow it to accumulate quite as much as it would have. Carpets are significantly more full of dust than hardwood floors, when you go to vacuum them.
What is happening is, under random jostling of the dust, there is some sort of probability for it to go from one to another, from the low shelf to the high shelf, from the carpet to the couch, and that is equalizing, so that roughly the same amount of dust on a given day goes from one shelf to another, or from the carpet to the wood floor. The density does have to do with it, but it's not a direct relation. The more dense the dust is in a thing, generally, the more likely it is to give dust to its surroundings that are less dusty than it. But different things -- carpet, hardwood -- hold dust more or less aggressively.
We call this quantity the “chemical potential” of the dust and two surfaces exchange dust until they come to the same chemical potential. It has to do with the amount of energy that is released by dust being in one place instead of another, which is why high places get less dusty than low places. A vertical surface costs more binding energy for the dust to stick there so dust does not settle so much on vertical surfaces. I say “surfaces” but also the air has a chemical potential for dust, and they all come to equilibrium.
One could even define that a carpet has more “dust accumulation spots” for dust to occupy, such that one could eventually discover “at equilibrium, each spot contains the same amount of dust, proportional to the chemical potential.” In that precise sense, the density is independent of any surface characteristics.
So temperature is just a chemical potential for energy itself, and one can similarly identify “degrees of freedom” that an object can move and this store energy: and in this precise sense the temperature is the average energy in those degrees of freedom. But when you are defining it, and you don't want to reference degrees of freedom, like with the dust, you define it just by the tendency of two systems in thermal contact to donate energy to each other through random jitters and jiggles. so it's literally defined by the fact that energy goes from a surface of hot temperature to a surface of low temperature, but it does have an indirect connection to average thermal energy density inside an object, since if you increase that energy density, the object wants more to give energy to other things. But it depends a lot on the properties of the object too, how many degrees of freedom it has, how much it wants to give that energy away. If it's a “carpet” like liquid water is, it takes a lot of flow of thermal energy to change the temperature. and that's just because it's got lots of degrees of freedom.