The endosymbiotic theory explains the origin of eukaryotic cells and how they got their chloroplasts and mitochondrion.
Based on theory, it is said that mitochondria and chloroplasts were originally single prokaryotic organisms that were engulfed by the eukaryote. (It is found that mitochondria and chloroplasts have their own DNA, so that is why it is thought that they were not originally a part of the eukaryotic cell.) Anyway, mitochondria and chloroplast soon developed inside of the eukaryote and became a necessity of the cell.
I hope this helped you. If it helped please give me a thanks.