Humidity has exhibited experimentally either beneficial or detrimental effects on the charge carrier lifetime of CH3NH3PbI3 perovskites, leaving the mechanism unresolved. By using ab initio nonadiabatic molecular dynamics simulations, we unveil the dual role of humidity stemming from the complex interplay between water and defects. Beneficially, water passivates iodine vacancies (VI) or grain boundaries (GBs), mitigating electron trapping by reducing nonadiabatic coupling and delaying charge recombination. However, when VI and GBs coexist, water molecules make the two unsaturated lead atoms approach closer and exacerbate electron trapping by deepening the Pb-dimer electron trap that was created by the VI defect, shortening the carrier lifetime to half of pristine CH3NH3PbI3. The study uncovers the origin of the positive and negative effects of humidity on the charge carrier lifetime of perovskites and offers strategies for improving perovskite devices, particularly by avoiding simultaneous point defects and GBs.