They never seem to be discussed in this context and didn't seem to be involved in The alliance system prior to the war. What were they up to? Thanks
As you said, they weren't particularly involved in European politics and had no major alliances with any power that would bring them into the war.
Economic: Spain was a very agricultural country even up into the the beginning of the First World War when you compare them to other major powers like Germany or Great Britain. Additionally, Spain was going through a period of economic 'uncertainty' just before the war - there was a lot of unrest and violent protests by labourers and working class citizens, especially during the Second Melillan Campaign. These poorer citizens were being conscripted, while rich people could get off by paying a fee (cont. below). Many prime ministers and their governments were forced to resign, and those who did not were voted out of office.
Military: In 1898, Spain was humiliated and severely weakened by a war with the United States, in which the Spanish empire basically came to an end after losing Guam, Puerto Rico, Cuba and the Philippines. Not to mention, the Second Melillan Campaign was a complete disaster for the Spanish. In 1909, just five years before WWI, Spain attempted to suppress militant rebels in north Africa. The Spanish won, but at a great cost. If Spain couldn't handily beat some armed peasants, why would they expect to beat France, Germany, Italy, or GB?
It's also worth noting that Spain benefited greatly during the war. Fruits grown in Valencia and the production of steel throughout Spain could very easily be sold to any country that needed them (steel was especially desired). Spain also tripled her gold reserves during the war and managed to pay down a significant amount of debt as well. Even though Spain ultimately lost 140,000 tonnes of shipping to u-boats, Spain was clearly too weak to do a lot. Even if Spain wanted to fight, it's military was too weak and her own people did not want war. Besides, Spain was making a nice profit from the war and so had no desire to join.
Sources:
Keegan, John. The First World War. New York: Alfred A. Knopf, 1999.
Payne, Stanley G. A History of Spain and Portugal: In Two Volumes. (2). Madison: The University of Wisconsin Press, 1973.
edit: a word