There are many theories as to how the first life on Earth came to be, including the hydrothermal vents and Panspermia theories. While those explain how the most primitive types of cells came into existence, another theory is needed to describe how those primitive cells became more complex.
The Endosymbiotic Theory is the accepted mechanism for how eukaryotic cells evolved from prokaryotic cells. First published by Lynn Margulis in the late 1960s, the Endosymbiont Theory proposed that the main organelles of the eukaryotic cell were actually primitive prokarytoic cells that had been engulfed by a different, bigger prokaryotic cell. The term "endosymbiosis" means "to cooperate inside". Whether the larger cell provided protection for the smaller cells, or the smaller cells provided energy to the larger cell, this arrangement seemed to be mutually beneficial to all of the prokaryotes.
While this sounded like a far fetched idea at first, the data to back it up is undeniable. The organelles that seemed to have been their own cells include the mitochondria and, in photosynthetic cells, the chloroplast. Both of these organelles have their own DNA and their own ribosomes that do not match the rest of the cell. This indicates that they could survive and reproduce on their own. In fact, the DNA in the chloroplast is very similar to photosynthetic bacteria called cyanobacteria. The DNA in the mitochondria is most like that of the bacteria that causes typhus.