Jon Doe joined Cobra at the age of 16 to get away from the Chicago orphanage he was raised in. The Cobra recruiter promised a life ten times better than the one he was living. He took to the training and soldiering like as if he were born for it. After only a few missions where his bravery and battle wits led to success he was recommended for Officer training. Again he flourished.
As an officer, he started noticing the inabilities of the Cobra High Command. Their infighting and desire for self preservation above all else led to many botched missions that could have easily been won. On one of these missions, Doe was captured by GI Joe. He was sure Cobra would launch a rescue attempt. The Joes let him wait.
When no one came he was so infuriated at being considered disposable that he broke down and told the Joes all the details they wanted to know. When he was done, the Joes were going to send him to a maximum security prison. However, his understanding of Cobra's inner workings and thinking made him a valuable resource. With his knowledge they had a better idea of how Cobra would operate in the future.
The Joes gave him a choice, he could either accept the rank of Lieutenant and serve under Psyche Out in the psychological warfare department or he could live out his days in solitary confinement in Leavenworth. He accepted and took on the codename X in recognition of his blocking out his past and starting over from scratch.
I really wanted that WWII and Cold War spy look.