Sometime around four billion or 3.5 billion years ago, lipid membranes and RNA or DNA got together to form the earliest living cells on Earth. Nobody understands exactly how this happened. But somehow some RNA or DNA molecules, or both, started hanging out in the water inside the bubbles of lipid membranes. This turned out to be to the advantage of the RNA and DNA molecules, because it protected them from water currents and other things and helped keep them from breaking apart.
So natural selection caused more of the RNA and DNA that was inside bubbles to survive, while more of the RNA and DNA that was outside bubbles died. After a while most of the RNA and DNA was inside lipid membrane bubbles.
Like the RNA and DNA that were inside them, these simple cells were able to reproduce themselves. One cell could become two new cells. The cell began by using RNA molecules to make a copy of the cell’s DNA. Then, with one copy of the DNA in each half of the cell, the cell’s membrane would pinch itself in the middle and split apart, making two new cells, each pretty much the same as the old cell (except if copying mistakes had happened during the copying of the DNA).