On healthcare it is a question of attitude of mind and of cost of the services. Remember that in Spain, as in the UK, the vast bulk of the facilities used are paid for by the government and there is already in place a system of universal healthcare paid for from taxes. Further, in common with all of Europe, the attitude is that healthcare must be available as of right and not wholly dependent on whether or not an individual has or has not got private cover, for whatever reason, or whether e.g. they are past retirement age or not .It follows that Spain will offer healthcare to anyone resident there, whether or not they are resident there legally. I can't say for sure but I expect that Spain does have provision against health tourism . That is where people travel to the country, from outside the European Union, just to get free treatment for specific conditions or to get a specific procedure done and then promptly leave. At one time this was quite a problem because the qualification for treatment was low or badly monitored in some countries.
Spain seems to have taken the view that, if their government insists on proof of legal residence before providing healthcare, there may be sick people, illegals,resident long term in Spain who dare not present themselves for treatment.That would seem, to the government, wrong and contrary to the spirit that produced universal healthcare in the first place.The numbers involved may not prove to be very large. Not every illegal is going to need the care, after all. (This thinking may have been extended, lest, for example, the illegals fear that, if they present, they may lose any benefits they are illegally claiming).
You might think it all expensive. It isn't compared to what US insurers and the US government there pay out for its non-universal system.
The US spends c. 13.1% of her Gross Domestic Product on healthcare (2000 figure).The UK spent 7.3%. The typical European Union country spends similarly. I've no figure for Spain herself but those European figures I could find are around the 8% mark (France's is quite high at 8.8% )Those figures are totals, including private healthcare, not just government expenditure.
US spent $4,449 per head of population on healthcare in 2000. (UK $1747 and France $2051 ) Of the US figure only c45% is public expenditure, incidentally.
We cannot say whether the US system is value for money or not but , no doubt everything costs a lot more over there.
Incidentally the UK is unusual in that no money at all is demanded of the patient for treatment and this is regardless of their circumstances. Elsewhere, naturally, some categories of people are always exempted from contributing anything at all, though, in any case, treatment is not to be refused. In France, for example, the government sets the costs of treatment and pays 75% of the cost of the treatment of an employed person, looking to the employer, a private insurer or even the employee to pay the balance. This seems to have absolutely no effect on take up. It was intended originally to stop the wasting of doctors' time by people presenting with trivial complaints, which they could deal with themselves or by asking a pharmacist, and general time wasters. French people were reputed to be hypochondriacs, so this fear was understandable

(As it is there is still nothing to stop them touring around until they find a doctor whose opinion or whose practices they prefer; and they do. This is known as 'nomadisme' ) The French system is still one of the best in Europe, nomadisme or no. Incidentally my French doctor gave a strange insight into his patients. He says that they all expect him to take their blood pressure, quite regardless of the complaint they present with. It could be a sore ankle but unless he takes their blood pressure first he is not a
real doctor in their, French, eyes and they regard him with some suspicion. At least it doesn't cost the system anything

[Sources: WHO and the Center for Disease Control (of the US Department of Health)]