because density is related to activity of particles, the higher the activity level (the faster they're moving, and distance between them) the less dense they are. for example, H2O in a solid the particles are close together with minimum movement and it exists as ice, but when heat is applied the particles become more active and move more decreasing the density becoming liquid water, then when excessive heat is applied the same occurs and it becomes gas steam