Spies can be used for all kinds of schemes - from scouting out your enemy’s forces, to sabotaging their industry, to stealing their tax revenue. The espionage menu allows you to recruit spies to place in enemy provinces, where they will report daily on their discoveries and take any actions you have assigned to them.
Placing spies in your own territory will convert them to counterspies, and they will attempt to block any enemy spy action that takes place in that territory. There is an element of prediction here, as you must try to ascertain which of your provinces the enemy spies are lurking in, while also evading their counterintelligence with your own agents.
A fairly common and clear indicator of enemy saboteurs is that your factories and railways seem in constant need of repair. Assigning counterspies to your industrial centres is vital to keeping them running.