DNA is a complex system with built-in error-checking and the like, but that doesn’t mean that it’s the only way life can reproduce – we still have RNA for instance which is simpler. So it’s likely that there were a series of replication mechanisms, each getting more sophisticated and therefore out-evolving the simpler systems.
As to where it started from originally – well, yes, it could have just been chance. Enough chemical reactions, enough lightning strikes, something might spark up. Or there’s the panspermia theory, where life spreads between the stars.
Remember, you don’t have to look at the odds of life originating on this planet, you have to look at the odds of life evolving anywhere in the universe, with million of galaxies each with millions of stars. That’s the beauty of the anthropic principle.