The main function of mitochondria is the production of ATP through cellular respiration. Other functions of mitochondria include heat production, programmed cell death, regulation of the metabolic activity in a cell and the storage of calcium.
When mitochondria produce ATP, they produce energy. The mitochondria takes the nutrients of a cell and transfers those nutrients into energy in the form ATP. ATP is what carries chemical energy throughout a cell for the cell to operate properly. The more energy a cell needs, the more mitochondria it will have. If a cell requires more energy than is available, it has the ability to create more mitochondria as needed. Mitochondria even have the ability to combine with each other to form larger mitochondria. Some cells, such as red blood cells, will not have any mitochondria, while other cells will contain hundreds.
Only eukaryotic (plant and animal) cells contain mitochondria, and therefore they are membrane-bound organelles containing both an outer and inner membrane. An interesting feature of mitochondria is that they contain their own DNA located outside the nucleus. This is what gives mitochondria the ability to duplicate autonomously from the cell and hence produce more of itself when more energy is needed.