I'll leave it for @Peter Kampf to explain the math, but I find it's easier to conceptualize static stability if you simply think of the airplane as a weathervane turned so its pivot axis is horizontal. Static stability simply is the forces making it point into wind, except the wind is changing in a vertical direction rather than a horizontal one.
Instead of the weathervane's pintle, the pivot is the aircraft's center of gravity. The "vane" of the weathervane, the part the wind is blowing on to align it, is the aerodynamic center of the horizontal footprint of the entire aircraft, the sum of all of the dynamic forces acting in a vertical up or down direction on the fuselage, engine nacelles, wings and tail. This is the Neutral Point.
The Neutral Point has to be behind the pivot, the Center of Gravity. Any change to the configuration that changes the aerodynamic horizontal footprint shifts the Neutral Point. Going back to the weathervane, if you tape a piece of cardboard to the back of a weathervane, you've moved its Neutral Point aft and it wants to point into wind harder. It's more stable. Tape a piece of cardboard forward, and you move the Neutral Point forward, reducing its stability or pointing tendency. Tape a big enough piece so there's equal surface area on each end, and you move the Neutral Point to the pivot axis and the weathervane no longer points but just wanders any which way. Its stability is neutral. Tape an even bigger piece, and the vane wants to switch ends until it finds stability going the wrong way. It's unstable.
So the question is basically how big does the tail have to be so that the overall aerodynamic center, the Neutral Point, of the entire airplane is sufficiently aft of the Center of Gravity for an adequate pitch axis "weathervaning" tendency, or positive static stability. Making the tail bigger moves it aft, making it smaller moves it forward. The formula for longitudinal stability derives the surface area required of the tail when its influence is combined with the aerodynamic forces acting on the overall horizontal footprint of the entire body.
This is what got Boeing into trouble with the MAX. The engine change, moving the nacelles forward, basically shifted the aerodynamic center of the weathervane too close to the pivot axis (the most aft C of G), reducing its "pointing ability" in certain flight regimes. As if you'd added surface area to the front end of your weathervane.
Beyond that, you then get into trimming forces, or the use of opposing pitching moments between tail and main wing to create force balances that allow the aircraft to point "off wind" (vertically), which gives you the ability to maneuver and be stable at various angles (angles of attack on other words, which you need to do to make the wings lift in the first place) other than directly into wind, as well as have good dynamic restoration characteristics. Without trimming forces, the airplane becomes a very statically stable lawn dart.