Because the heat is leaking out, the center of the Sun is becoming slightly cooler. A cooler temperature means that the gas pressure is becoming slightly smaller, and the pressure that resist the pull of gravity is slightly less. So the outside of the Sun shrinks a little. This additional shrinking reduces the radius of the star and, since the mass remains the same the effect of gravity increases. This puts the Sun's center under a bit more pressure.
More pressure means more temperature.
More temperature means more heat and more radiation, which then leaks out. And the process continues. William Thompson, better known as Lord Kelvin, considered this scenario in the middle of the 19th century. He realized that the entire energy of the Sun could be produced if the Sun was shrinking about 1 centimeter per year. He also calculated that through gravitational contraction, the Sun could successfully maintain its brightness for about 40 million years.