Nobody really knows.
Once, a commonly held belief was that the first building blocks of life formed in a primordial soup of chemicals in an ancient, warm ocean. In a famous experiment in 1953, chemists Harold Urey and Stanley Miler cooked a flask of water, methane, ammonia, and hydrogen, and sparked it with electricity. The experiment, many people felt, proved the old assumption. But later research revealed that perhaps the gases Urey used in his experiment weren't as common in the early atmosphere as he had thought - and that the sheer size of the oceans might have made any amino acids formed much too dilute to form into anything useful. One theory holds that perhaps RNA, not DNA, was first out of the starting blocks.