A primordial origin for the compositional similarity between the Earth and the Moon