Density was first discovered in 250 B.C.E. by Archimedes, a rather famous Greek mathematician of the time. In fact, he discovered as a by-product for a certain task he was charged with.
As the historical story goes, Archimedes was tasked with determining whether or not the King of Syracuse's craftsman was lying to him about the purity of the golden crown presented to the king.
The king had a suspicion that the crown he had gotten was actually a fraud, mostly made of silver instead of gold.
Later, Archimedes drew himself a bath. When he got in the tub, he noticed that some of the water spilled out, which got him thinking.
He recognized that his body mass displaced some of the water, and he then had the first thoughts about what a material's density could mean. He decided to test the crown in a similar manner.
He placed the crown in question and a truly pure gold crown in a tub of water. He knew that silver had a lower density than gold and would, therefore, displace more water since the mass of the two crowns were the same.
He found that the crown in question was, in fact, a fraud! It displaced more water than the pure gold one.
You might have heard the famous line, "Eureka!", which is associated with figuring something out. We have Archimedes to thank for that, who shouted the Greek phrase when he discovered the lies of the king's craftsman.