The atomic cluster models of α-Mg, liquid Mg and the interface between liquid/solid have been founded by computer program. The environment-sensitive embedding energy of RE elements in α-Mg, liquid Mg, liquid/solid interface has been calculated by recursion method. The atomic affinity energy between Mg, La, Y with O has been defined and calculated. The calculated results show that the solid solubility of La and Y is very small in α-Mg, because their higher environment-sensitive embedding energy leads to instability in α-Mg crystal. The RE elements diffuse to the liquid Mg, which has lower environment-sensitive embedding energy than the solid, and congregate on the surface of liquid Mg as the alloy solidifies. Because the atomic affinity energy of RE-O is lower than Mg-O(The atomic affinity energy between Mg, La, Y with O are Mg-O：-14.9338eV，La-O：-19.0608 eV，Y-O：-19.5050 eV, respectively), the RE elements congregating on the surface of liquid Mg will priorily combined with O, forming compact RE oxides, which prevent Mg alloys from burning.