Hans Christian Oersted discovered in 1820 that an electric current can produce a magnetic field, revealing the relationship between electricity and magnetism.