You don't know who is planning or not planning an invasion. You don't know who will or won't help you in a war. You don't know troop composition, disposition, or strength. You don't know how the cookie will crumble due to current political winds. You don't know a goddamn thing unless you spy on them.
You can put two and two together, and fill in the blanks with educated guesses, inferences, and patterns... that is one tool. Other tool is spying. Without either you are a total SHIT craftsman.
"International Law" are nothing but agreements between countries backed up ONLY by what the angry country can do about it. There is no power on earth above the nation-state. At that level, each country does what it can to do what ever is necessary for its own survival in the realpolitik game. And maintaining economic power is just as important as how many tanks you have. More, actually.
Countries don't go to heaven. They don't get any credit for doing what is "right", only for doing what is "necessary". Spying, blackmail, assassination... all of it bad and distasteful, some of it necessary. Like war.
If you yourself live in any kind of comfortably safe society, you have benefited from a strong nation-state somewhere willing to spy and fight where necessary. Even if you don't live in said country. Even if you don't appreciate it.