Nitrogen-rich and water-rich compounds are common in interstelar clouds which contain formaldehyde, ammonia, methane, water and other molecules. Comets are samples of this primitive matter, and the young earth accreted from a cloud that was very very rich in water and nitrogen-rich compounds just like interstellar 'molecular' clouds are known to be. So the early atmosphere was very rich in these molecules, however, after the sun went through its T-Tauri phase, it stripped the earth of these early molecules, so we think that the way nitrogen and water got back to the earth to form the second atmosphere is through comet bombardments when the earth was still less than 1 billion years old.
All answers are provided by Dr. Sten Odenwald (Raytheon STX)
NASA IMAGE/POETRY Education and Public Outreach program.