To know the answer we have to go back to what was discovered about the rocks brought back from The Moon (Luna). It was discovered that those rocks were of the same type as found in Earth’s crust but scientists were already sure that the Moon and Earth formed separately.
It took time but eventually it was concluded that, somehow, a big chunk of early Earth was thrown into space and into orbit around Earth (at much lower distance and at much faster orbital speed). It was also clear that meant the Earth had somehow survived an impact by a large object which struck the Earth just enough off-center to avoid blowing Earth apart completely.
A lot of computer power was applied to this theory and after running a number of theoretical models for that event, a model was found that matches the results completely. Now we have computer animations of the event which have appeared in documentaries about the Moon and Solar System, etc.