The origin of photosynthesis and oxygen on early Earth