Rocks in the mantle and the core are still hot from the formation of the Earth about 4.6 billion years ago. When the Earth formed, material collided at high speeds. There is also heat within the earth produced by radioactive decay of naturally-occurring radioactive elements. It is the same process that allows a nuclear reactor to generate heat, but in the earth, the radioactive material is much less concentrated. However, because the earth is so much bigger than a nuclear power plant it can produce a lot of heat.
Rocks are good insulators so the heat has been slow to dissipate.
This heat is enough to partially melt some rocks in the upper mantle, about 50-100 km below the surface. We say partially melt because the rocks don't completely melt. Most rocks are made up of more than one mineral, and these different minerals have different melting temperatures. This means that when the rock starts to melt, some of the minerals get melted to a much greater degree than others. There will be a little bit of molten sugar in your magma, but not much, most of it will still be crystalline.