Every spacecraft that comes home from space has to survive re-entry — the process of slowing from orbital velocity (about 17,500 mph for Earth orbit, 25,000 mph for return from the Moon) to landing velocity. The slowing happens in the atmosphere, and the energy of that deceleration goes somewhere: mostly into heat.
The heat is extraordinary. At lunar return velocity, the heat shield on the command module faces temperatures of about 5,000 degrees Fahrenheit — hotter than the surface of the Sun (the photosphere is about 10,000°F, but hotter than most stellar atmospheres). The heat would melt any metal.
How does the spacecraft survive this?
The answer, developed by NACA researcher Harvey Allen in the 1950s, is counterintuitive: use a blunt shape, not a streamlined one. A sharp nose pushes air aside efficiently; a blunt shape creates a strong bow shock wave ahead of the vehicle, which does most of the heating of the air. Most of the energy goes into heating the shock-compressed air rather than the vehicle.
The heat shield material is an ablative substance — a material that absorbs heat by burning away. The Apollo heat shield is made of Avcoat, an epoxy-resin compound embedded in a fiberglass matrix, filled with thousands of small glass bubbles. When the heat hits, the outer layer vaporizes — ablates — carrying heat away from the shield surface. The char layer that remains is a good insulator, protecting the layers beneath.
The shield on Apollo is about an inch thick at the base. It loses a fraction of that thickness during re-entry. The remainder protects the crew.
The shape matters too: the command module comes in blunt-end first, presenting the maximum surface area to the airflow. The center of mass is off-center, which causes the capsule to fly at an angle — a slight angle of attack that creates lift, allowing some steering during descent.
Physics turned into engineering. The understanding of what happens at Mach 25 in a blunt-body bow shock, written up in a technical report in the 1950s, keeps three astronauts alive every time they come home.