Those two properties have nothing to do with each other (almost).
Density is a result of atomic mass (adn density) and stacking arrangement, how many atoms actually fit into a space.
In general low density and low atomic number are related.
Hardness (and a bunch of other mechanical properties) are related to how the atoms are bonded to each other. This is impacted by the nature of the elements and their stacking order to some degree (presence of slip planes and such).