I don't know this part of EU law well enough to give a definitive answer regarding its interpretation and application in practice but requiring sufficient resources is definitely allowed.
My reading of the relevant directive and my understanding of the general logic of the system is that non-economically active EU citizens should not be a burden to the host state. The criteria would therefore seem to be that your wealth and/or income are above the threshold to receive welfare benefits in that particular country. Similarly, you could be required to already have health insurance and not to get it in Spain (for example retirees are typically covered by the country they receive a pension from, not by the country they live in).
If that's an option for you at all, a practical solution around this issue could be to get a job (almost any job should do, freedom of movement for workers is very thorough and largely distinct from other provisions) but I imagine it might be especially difficult in Spain at the moment. Establishing yourself as a self-employed service provider could work as well (it will cost you something but it can sometimes be even more open, e.g. for Croatian citizens who are subject to restriction to the freedom of movement for workers in many countries).
If you don't want to work but can't show that your needs are covered, e.g. by the pension and health systems of your country or origin, you might be able to reside somewhere else in the EU but you don't have a right to do so.
This press release from the EU commission provides an overview.