(My post on VJTI1977 group (16 May 2014) as a time-pass till the election results poured in).
Spying has been practised by states since ancient times. Kautilya's Arthashastra (KAS: circa 350BC edited till 400CE) devotes two separate Chapters - chapter 11 and 12 - for spying and its institutions. This more than 2000 years old voluminous Sanskrit treatise of "political management" (15 books, 150 chapters, and 6000 shlokas) is quite amoral in the deployment of spies even within its own state.
As a sample:
Book-I, Chapter12: < A poor but clever Brahmin widow can make her earning through spying by being part of "King's harem". She shall frequently visit King's senior ministers (for spying and extracting information) >. The amoral nature of KAS in general and spying in particular is quite obvious here.
Spies can be deployed within state to guard against mutiny and externally to guard against aggression. However, KAS differentiates between friends and foes. In its concentric circle theory friends and foes alternate in concentric circles by following the maxim - your enemy's enemy is your friend. This conceptual arrangement breaks when Kingdoms (Janapadas) want to grow into bigger Kingdoms (Mahajanapadas) or into imperial Kingdoms (Samrajyas) by aggression. In the medieval past, the ambitious kingdoms used to grow by defeating neighbours (natural foes) and making them part of their own kingdom. An imperial state as such could deploy as many spies as it can blurring the boundaries between friends and foes in the process of growth. It follows the age old dictum "might is right"
KAS has been an extremely influential ancient treatise. Its political management is quite detailed and had served as a model for many medieval monarchies.
However we have to remember two things:
(a) KAS differentiates between friends and enemies when the kingdom is stabilized even though its spying institution is basically amoral in nature.
(b) KAS is applicable to monarchies - to monarch (king) and his feudal network. Strictly speaking it is not applicable to modern liberal democracies.
The very fact that even today most of the countries have their own spying agencies and some countries spy on frinds as well as foes has its own story to tell.
(General Source: Kautilya Arthashastra, translated by R. Shamasastry, Bangalore Government Press 1915)