The electronic structures of lead styphnate, hexa(1,5-diaminotetrazole) cobalt perchlorate, lead azide, (5-cyanotetrazolato-N (2)) pentaammine cobalt perchlorate, and tris(carbohydrazide) zinc perchlorate were investigated via density functional theory. The results obtained reveal that the electrostatic spark sensitivities of these primary explosives are related to their electrostatic potentials and energy gaps. Highly sensitive primary explosives show large cell electrostatic potentials per unit volume and small energy gaps. Moreover, the energy levels of the frontier molecular orbitals play an important role in triboelectrification between an explosive and a flume. The lower the energy level of the lowest unoccupied molecular orbital of the primary explosive, the more easily it can accept electrons and accumulate negative charge.