The electronic structures and the optical properties of pyrite containing twenty natural impurities, Co, Ni, As, Se, Te, Cu, Au, Ag, Mo, Zn, Tl, Sn, Ru, Pd, Pt, Hg, Cd, Bi, Pb and Sb, are investigated using the density functional theory and the plane wave pseudopotential method, and the catalytic activity of pyrite is discussed. For the transition metal-bearing pyrite, there are introduced impurity energy levels in the band contributing from impurity d orbital, while for the other metal and non-metal-bearing pyrite, the impurity energy levels are contributed from impurities s or p orbital. The presences of Cu, Mo, As, Au, Ag or Ni can enhance the electrocatalytic ability of pyrite to the oxygen reduction. All the impurities, except Zn, Mo, Ru, As, Sb, Se and Te, can enhance the ability of pyrite surface to capture electrons and hence the recombination rate of photoinduced electrons and holes wile be reduced. Calculations of optical properties indicate that Cd, Hg, Ru, Se, Te and Zn impurities each have small influence on the absorption band edge, while the presence of other impurity makes a red shift of absorption band edge of pyrite. Especially, the presences of Au and Ag impuritie increase the adsorption coefficient of pyrite by two orders of magnitude.