It's actually believed that chloroplasts and mitochondria used to be their own unique, single-celled organisms, which evolved to work symbiotically with the bigger, eukaryotic (more complex, with a true nucleus) cells that were beginning to develop and become more complex. The relationship made a lot of sense: the chloroplasts and mitochondria would get lots of free food from the host organism, and in exchange it would help make energy for its host through photosynthesis or respiration processes.
So those two organelles kept their DNA through today, because they're still kind of their own thing. That also leads to an interesting quirk: because a female's egg cells contain mitochondria but a male's sperm cells don't, all mitochondrial DNA is passed down from the mother - in other words, I have my mom's mitochondria, but not my dad's. This can be used to track descent down the female line.
It is believed that chloroplasts and mitochondria used to be separate organisms that enjoyed a symbiotic relationship with other single celled organisms. The relationship was so close they were fully incorporated into cells as organelles.
Today, they still have their own DNA, which is passed down separately from nuclear DNA. They undergo the same sort of evolutionary processes regular DNA does, although since they do not reproduce sexually, the rate of change is slower.