Spy, like the word “fire,” can be an extreme positive, or an extreme negative. It depends on how the act of spying is used.
The State of Israel exists, despite 75 years of being surrounded by countries determined to annihilate it, because of brave individuals who risked their lives in order to obtain crucial information by being spies. Eli Cohen (may his death be avenged) spied for the state in its early years and was executed by Syria in 1965 for doing so. He was 40 and left a wife and three children. But the intelligence he gleaned over the years was invaluable.
On the other hand, the miraglim – the spies sent by Moshe to report on Eretz Yisrael – came back with very discouraging news about the potential success of an invasion, leading to the entire nation wandering in the desert for 40 years.
Sometimes, spying can lead to lashon hara and toxic misinformation that can lead to the destruction of reputations. For example, some schools have spies to see if their students are frequenting “banned “ places, like skating rinks and pizza places. This leads to their being malshinim – snitches – which Judaism views as a serious transgression.
Like fire, the act of spying can be life-saving, or life-diminishing.