A novel polymeric ionic liquid (PDBA-IL-NH2) using imidazolium ionic liquids with short alkyl chains as monomers and two control ionic liquids (PDBA-IL-OH and PIL-NH2) were synthesized. Their inhibition properties and mechanisms were explored via surface analysis, weight loss tests, electrochemical studies, and adsorption isotherm analysis. The corrosion inhibition efficiency (CIE) of PDBA-IL-NH2 gradually increased with increasing concentration, and the largest efficiency was 94.67% at 100 ppm. At the same concentration (50 ppm), the corrosion inhibition abilities of inhibitors were in the order of PDBA-IL-NH2 > PDBA-IL-OH > PIL-NH2 > IL-NH2. Based on the experimental investigation, the synergistic effect of electrostatic interaction, protonation, and electron donor-acceptor interaction facilitated the intensive entanglement and coverage of PDBA-IL-NH2 with the reticulated form on the metal, and the generated densest films protected the metal from the corrosive media. Ultimately, the theoretical results of molecular dynamics simulations and quantum chemical study were in high agreement with the experimental data, which confirmed the proposed inhibition mechanisms on the microscopic scale. This study contributed valuable perspectives to the design of efficient and ecofriendly corrosion inhibitors.