>>38043826I'm so glad you asked. This is a matter of some debate, but one popular theory is that it all started with an unicellular prokaryotic archaebacterium engulfing a mitochondrion floating in some primordial soup 1.45 billion years ago. Instead of just digesting it, this particular archaebacterium found a symbiotic benefit in keeping the mitochondrion in its belly. Back then, it would have been because the mitochondrion could produce H_2 as a source of energy for the archaebacterium. The mitochondrion, on the other hand, benefited from being protected from the scary world out there by being inside the bacteria.
What happened when the bacteria underwent mitosis? Well, the smaller mitochondrion had multiplied a couple times by then, so about half of them went with each new bacteria, spreading the parasitoid relation.
Over the billion and a half years since, mitochondria developed the ability to work with ATP and truly became the powerhouse of the cell, and it all snowballed from there, with all successful multicellular life on Earth ending up using this mechanism for chemical power generation.
Fun fact, the mitochondria are passed down solely through the mother, because we get them from the ovum where the conception occurs, not from the combined genome of the two parents.