The investigation into the anonymous threatening emails might not have led to General Petraeus or uncovered the affair, but the FBI discovered that someone at the same suspect IP address was also accessing another Gmail account--an account that belonged to the director of the CIA.
General Petraeus and Paula Broadwell didn't actually send emails to each other: They used a trick from the terrorist playbook and simply wrote messages that were saved as drafts in a Gmail account that belonged to Petraeus, and they would each log into the same account to read the drafts and respond.
If you wish to remain anonymous, and avoid having someone connect the dots that lead back to you, you should use different service providers. While it would still be possible with enough digging to determine all of the activity for a given IP address, it would not immediately jump out as a red flag as it did in this case.
Don't leave your messages online
Petareus and Broadwell had their reasons for using secret drafts rather than sending emails to each other. Perhaps the two reasoned that the email messages couldn't possibly be intercepted or traced if they were never sent. That is true to an extent, but it means that the messages are stored online--more or less permanently--allowing them to be stumbled upon at a later date.
While it's true that messages might be intercepted in transit, it would be more secure to download the emails to a local email client and remove them from the server. At least then you only need to worry about securing and protecting your own PC, and you don't need to be as concerned about a possible breach or violation of privacy on the email server or webmail provider end.
You may not be a decorated military officer or high-profile government official, and you probably aren't even the biographer of one. But, this sordid affair is a stark illustration of just how easy it can be to trace someone's tracks online, and uncover information that was meant to be secret. Make sure you follow the tips here to avoid falling victim yourself.