One of the main ways we have learned about the earth’s interior is by studying earthquakes.
Scientists have learned a lot about how vibrations (which is what earthquakes are) travel through different types of materials (solids, liquids, semi-solids.)
Imagine you take a big rock and put your hands on the side of it, while somebody else taps it with a hammer. You would sense different things if the person tapped right next to your hands, or if they tapped further away, or if they tapped on the far side of the rock. If your hands were really sensitive, and you kept a detail of what you felt, you would learn a lot about that. Then imagine doing the same thing with different materials, maybe a big jello mold, or an inflated basketball, or a bucket of water. You would pretty soon know what kind of vibrations would feel like from different kinds of taps in different places on different materials.
Scientists have sensors all around the world that measure earthquakes and other vibrations in the earth very precisely. Let’s say a big earthquake happens in Japan, it will be detected in Japan and the nearby region, but also in America, and Australia and Europe. By comparing the types of vibrations detected in those different parts of the world, and looking at how long they took to travel, scientists can infer quite a lot about the types of material that the vibrations were traveling through.
Then they take information from other scientists who have studied the kinds of stuff the earth is made of, and how those materials behave under heat and pressure. When the different groups of scientists put their data together they are able to form a pretty clear understanding of the composition of the interior of the planet without having to observe it directly.