The original gas, dust and small rocks that formed the earth were solid. They were small and exposed to the cold of space. They would have melted and flowed under gravitational pressure as the earth grew that's why the earth is spherical while asteroids and small moons are more 'lumpy'.
I'm not sure that the earth necessarily cooled into a complete solid before the heat input from radiation melted it again. Certainly the mantle and crust were 're'-melted but it might be that the core never solidified - sorry not quite my field.
The dates come from a combinatiopn of cooling rates, estimates of the total amount of radiation from level sof decay products and the dates of the oldest rocks found.