Primary endosymbiosis is the process in which a eukaryote engulfs another living prokaryote. An organism may then use that organism to its advantage. If a eukaryotic cell engulfs a photosynthetic alga cell, the larger organism can then use the products of the alga and become an autotrophic organism. But if the larger cell dies the smaller cell may not die and may leave the remains of the old cell to survive. Or if the smaller cell dies then the larger organism can stay alive. Scientists believe that this process has only happened a few times in history and is what leads to the creation and evolution of mitochondria and chloroplasts. An instance of this process would be when a cell long ago engulfed a photosynthetic Cyanobacterium. This bacterium would then become a plastid inside the cell and begin to share genetic material. A plastid is a major organelle found within plant and alga cells that contain and manufacture important chemicals. Over time this plastid evolved and became the current chloroplast.
Secondary endosymbiosis is when a eukaryote cell engulfs another eukaryote cell that has undergone primary endosymbiosis. This process has happened very often through time and has lead to the great genetic diversity we find on earth. The main difference between primary and secondary endosymbiosis that after the cell is engulfed it becomes dependent on the larger cell. It cannot leave and return to its original state. As you can see in the picture below there is a fairly large difference between primary and secondary endosymbiosis. After the initial endosymbiosis, the original hybrid cell reproduced and one of the new offspring was engulfed by another non-photosynthetic organism, allowing that new cell to be photosynthetic. This is all possible because of a double membrane that was made by the first layer of the endosymbiosis in primary endosymbiosis, and the membrane of the cell that was engulfed in secondary endosymbiosis forms the second layer. This is the reason that mitochondria and chloroplasts have a double phospolipid bi-layer.