It's only "no longer any security threat" because he got caught. The punishment is to dissuade anyone else from having an affair, which a foreign government could use to make their lives difficult by telling their spouse.
Too little, too late.
http://www.washingtonpost.com/politics/federal_government/ho...
> That agent’s role in the case consisted simply of passing along information from Kelley to the FBI agents who conducted the investigation, but that agent was subsequently told by his superiors to steer clear of the case because they grew concerned that the agent had become obsessed with the investigation, the official said. The agent was a friend of Kelley and long before the case involving Petraeus got under way, the agent had sent Kelley shirtless photos of himself, according to this official.