That is a really interesting question, never realised it!
Well: Look at this first as it tells you a whole lot about them. Then read this and you should have your answer. This is a forum to tell you a lot of stuff as well.
Why Ditto? Well, if you look at their genetic make-up, both Mew and
Ditto are the same. Both possess the genes of all Pokemon in
existence, as is evident in their ability to Transform into any
Pokemon (Smeargle does not learn Transform naturally, so it does not
count any more than a Pokemon getting Transform via Metronome).
So there are a LOT of theories of this but nothing has been proved...yet