In his book "The Deep Hot Biosphere" Thomas Gold argued that life probably originated deep underground. Gold is a pretty controversial figure, but this hypothesis makes sense for a number of reasons: the underground environment is a lot more stable than the surface, and the chemistry to extract energy from the chemicals in that environment is a lot simpler than the chemistry to extract energy from sunlight. So it makes sense that underground chemosynthesis would emerge before photosynthesis.