Spain was losing influence in America for the previous 100 years, and there was a recent Spanish-American war. So how could have Spain remained neutral?
Why could Spain not find a place in the Central Powers?
Complimentary to Tom's answer, you have to ask yourself which side they'd come in on. There's nothing really useful in terms of territory they could get out of Germany or Austria-Hungary, since both were way on the other side of Europe.
If they'd gone in on the other side, they could perhaps have gotten useful territory from France. However, French forces were generally considered much higher quality than Spanish, and the Pyraneese mountains would prove a very tough defensive line to crack. To make matters worse, they would have quickly found themselves with a two-front war, as Portugal was a long-standing British ally, and would certianly have gotten involved if England did (as had happened 100 years earlier at the start of the Peninsular War.
The biggest reason for Spanish neutrality I believe was their unique experience in the Peninsular War. This was the last time that Spain had allied itself with a major power, and that major power used the alliance to stab Spain in the back. The ensuing war was bloody, and almost entirely carried out on Spanish soil with Spanish blood. We get the term Guerilla Warfare from this conflict. When the smoke cleared, the winners and losers went home and tabulated their gains or losses, but Spain was in ruins economically, socially, and emotionally. So you can see where the Spanish would be a bit less inclined to join an alliance on a whim.
Lastly, the country was still getting over their humilation in the Spanish American war (known as "The Disaster" in Spain) a decade and a half earlier. Their government at the time was kind of a weird attempt to ape the form of the British Constitutional Monarchy, but without any real Democracy. Unsurprisingly, it had every bit as much real popular support as the people had real voices in it (iow: almost none). I suspect it was pretty clear to everyone it wasn't stable enough to engage in a foriegn war, and in fact it fell on its own about a decade after the end of WWI.
There were two power blocs, the Triple Alliance (Germany, Austria-Hungary, Italy), and the Triple Entente (Britain, France, Russia). Spain was part of neither and had no reason to support one or the other.(Italy later switched sides).
Spain was fortunate to be outside of the main battle areas: France, Belgium, Poland, the Balkans, western Russia. It had no reason to fight.
The U.S. was neutral until 1917, so Spain had no reason to side with the Central Powers on that basis. Nor did she have other common interests with them.
Spain was not prepared for the war in the Great War. It was on the process of modernizing the country, as the first industrial revolution reached Spain in this time.
Spain dit not have the capacity to build tanks or even airplanes, we have the Spanish-American war as a clear example. Spain has always had good soldiers but, at the moment of the Great War, it had a quite outdated techonology compared to some european countries or even the USA.
Spanish army and airforce got modernized in the 20's thanks to the strong ties with English companies forged at the end of the XIX century and at the early XX on Spanish northern and soutwest coasts.
Spain was better prepared for the WW2 than for the WW1, but the Civil War ruined its economy until US arrived on the 50's.
With a disaster war against Napoleon and later with the civil War spain was not ready. Spain Until Alfonso XII arrived to the power was very unstable country. the period 1874-1920 was to rebuilt and reset the industrialization. Not to say that Spanish-American war was called "the Disaster of 1898".
In terms of population, spain growth the half of the rest of european countries. Spain achieved to double its population in 60 years, while UK needed only 30 years.
The XIX. century for Spain was the century of the big decline that will not recovered with a great work in the periods of 1874-1975. the century of recovery (The Civil war and first period of Franco´s regime was an slowdown nearly 20 years).
In spite of saying that spain could not enter in ww1, it was very nearly the entrance in the war.
In the momentum of the entente cordiale between france and uk it was a secret agreement that involved spain in the case, If italy joined to germany and Austrian-hungary empires.
spain before the ww1 started was trying to make a new deal to improve the armada size with 5 battleships and several cruisers and destroyers and needed the permission of the uk.
Spain agreed that If italy joined to the central powers that will have provocked the intervention.
The agreement was composited in: 1. UK accepted spain to improve the armada. 2. 10 spanish divisions to support france in italian frontier. 3. 5 marine divisions to make an amphibious assault in Italy.
Spain was commited to intervene. However, italy declared neutrality first, but later joined with allies. So, the secret clause of the entente cordiale wasnt used.
Spanish position to be near the allies was the issue of marocco. France and spain made an agreement to divided the country, fact that Didnt like germany, however, Uk favoured spanish-french agreement weakening the German position. That involvement of germany was badly received by spain.
Spain was far away and unconcerned about the territorial-ethnic quagmire in the Balkans that provoked the war.
Also there were no acute rivalries with other Western powers as France-Germany.
No irredentism or disputed lands as future Price for the war effort.
And last, but not least, the financial effort to equip an army for the Spanish-American war meant that defense expenditures during the early 20th Century were minor compared with other powers (even Bulgaria or Romania). <> (We are neutrals, because we cannot be otherwise) a high ranking offecial was Heard to comment.
All this summed-up to the Spanish Realpolitik during the war years.