Denim was invented by accident in 18th-century France in the city of Nîmes. They were trying to copy an Italian fabric, serge, but they actually created “serge de Nîmes,” which was shortened to “denim.”
Levi Strauss brought it to America when he emigrated from Bavaria in 1853.