The heretics planted run-times within geth networks to spy on them, and planned on infecting the rest of the geth with a virus that would compel them to believe that worshipping the Reapers was correct.
If Legion is allowed to join the Shepard's team, they can go to Heretic Station in The Sea of Storms to stop the virus. Legion suggests that the virus could be re-purposed to reprogram the heretics into rejoining the collective or destroy them, thus depriving the Reapers of useful servants.