I believe that Earth has a mighty and powerful defense system. A system so powerful that Starfleet sometimes lets the Enterprise be the only starship in or near the solar system without fear of any trouble. Despite the fact that the nearest Klingon ruled star system is only a few days away according to Star Trek: The Motion Picture.
Starfleet command probably believes that the Earth defense systems can hold off any possible Klingon, Romulan, or joint Klingon-Romulan attack.
There are probably concentric systems of giant force field generators, giant phaser banks, and giant photon torpedo launchers in the outer solar system, the middle solar system, the inner solar system, in high Earth orbit, in middle Earth orbit, in low Earth orbit, and on the ground on Earth, each capable of withstanding any predictable attack from any known enemy.
The Earth defense system is nullified three times by unknown enemies far more powerful than Starfleet expects, in Star Trek: The Motion Picture, Star Trek IV: The Voyage Home, and a century later in "The best of Both Worlds". And no doubt after each time the Earth defense system is made even more powerful than before.
In one novel in the Lensman series the government ruling millions of planets in one galaxy assembles its fleet of millions of space battleships and invades another galaxy. The government of the second galaxy sends it fleet of millions of space battleships to intercept them. The fleet of the second galaxy is defeated and the fleet from the first galaxy heads for the capital star system of the second galaxy.
But when they get there they do not attack the two capital planets. They need to capture them intact to learn all the secrets of the enemy government, and they are powerless against the super powerful defenses of those two worlds.
That's right, planetary defense systems capable of holding off attacks by fleets of millions of space battleships.
I'm sure that Earth's defense system was designed to hold off attacks by any fleets imaginable to Starfleet's planners - fleets of tens, hundreds, or thousands of space battleships. So like the builders of the planetary defense systems in the Lensman series, they built defenses that could stop any attacks they could imagine - though on a much smaller scale.