The answer is: nobody really knows, but we can speculate. The usual theory goes like this. Before there was life on Earth, the planet had an atmosphere and an ocean. Both were made up of the same elements as today, carbon, hydrogen, nitrogen, and oxygen, but the amounts of each were very different. Scientist disagree on whether first life originated from those elements as gasses (atmosphere) or at the mouths of hydrothermal vents in the ocean floor. But begin it did.
Scientists think that an energy source, like lighting or the excessive heat from the ocean vents, zapped some carbon, hydrogen, nitrogen, and oxygen atoms, turning them into amino acids. These still weren't life.
First the amino acids had to combine. An experiment showed that heating amino acids, which had dried, caused them to join. When joined they are called protobionts--half way between inorganic (not living) and organic (living). These still weren't life either.
To become living cells the protobionts had to develop a a membrane, grow, and divide. Not much is known about how that happened but based on existing evidence, we think the first "living thing" was an RNA molecule (not DNA), because RNA can reproduce itself under certain conditions.
Adapted from Historical Geology, Wicander and Monroe, 1989.
making a small donation to science.ca.