The problem of the origin of the Moon is of fundamental importance to understanding the mechanism of the planetary solar system's formation. It is important to know the mechanism of differentiation of substances in a growing planet. When planets are formed from a cold protoplanetary cloud, the matter of the inner regions of the Earth and the Moon remains at temperatures lower than the melting point of iron. The main volume of the matter of the protoplanet remains in its unmelted state, and its differentiation occurs in the formed planet. In this work, attention is paid to the most important internal sources of energy: the decay energy of shortlived isotopes, the dissipation of tidal friction energy, and thermal energy from accidental deposition of bodies and particles on a growing surface. Accounting for these sources provides a solution to the problem.