Atoms move and combine to form other molecules.
Molecules likewise combine with atoms or other molecules.
Chance means some of the molecules will be self-replicating,
I.e.. they form copies of themselves.
But mistakes are sometimes made, leading to......
Mutations of the self-replicating...