Geochemical, cosmochemical, geophysical, and mineral physics data suggest that iron (or iron-nickel alloy) is the main component of the Earth’s core. The inconsistency between the density of pure iron at pressure and temperature conditions of the Earth’s core and seismological observations can be explained by the presence of light elements. However, the low shear wave velocity and high Poisson’s ratio of the Earth’s core remain enigmatic. Here we experimentally investigate the effect of carbon on the elastic properties of iron at high pressures and temperatures and report a high-pressure orthorhombic phase of iron carbide, Fe7C3. We determined the crystal structure of the material at ambient conditions and investigated its stability and behaviour at pressures up to 205 GPa and temperatures above 3,700 K using single-crystal and powder X-ray diffraction, Mössbauer spectroscopy, and nuclear inelastic scattering. Estimated shear wave and compressional wave velocities show that Fe7C3 exhibits a lower shear wave velocity than pure iron and a Poisson’s ratio similar to that of the Earth’s inner core. We suggest that carbon alloying significantly modifies the properties of iron at extreme conditions to approach the elastic behaviour of rubber. Thus, the presence of carbon may explain the anomalous elastic properties of the Earth’s core.