There are two factors which contribute to the immense temperature of the center of the Earth.
First is pressure. If one uses an old fashioned hand operated tire pump to blow up a tire, they could notice that the cylinder gets warm as the air is pumped through. The reason is that as pressure is increased, the temperature of the gas increases. Whenever the pressure on an enclosed system is increased, the temperature of the system will increase. This rule extends beyond gasses in a tube to include pressure being applied to liquids and solids as well.
The large mass of the Earth creates a strong gravitational field which pulls all of the mass toward the center of the Earth. The immense pressure of the gravitational force as it is applied to the core of the Earth creates a very large heat.
The second reason is radiation. The Earth is comprised of many radioactive elements. As these elements decay they release energy either in the form of kinetic energy from particle decay (alpha and beta) or radiant energy (gamma decay). Within the Earth these energies are not free to radiate into space and interact with other matter in the Earth. The kinetic and radiant energy is converted to thermal energy as it collides with atoms of other elements.
Due to the pressures at great depths within the Earth, the matter has a very high density. This high density concentrates radioactive material and increases the radiation-to-thermal energy conversion as you get deeper below the surface. Consequently the temperature of the Earth increases as one gets deeper.