what causes the earth to have layers?

Answer :

A greater gravitational force acting upon their mass
I’m guessing Radioactive decay , and gravity