It’s legal requirement that you are covered by student health insurance for the duration of your stay in Spain. If you are an EU, EEA or Swiss citizen, you can use your international health insurance (i.e. that of your home country) if you have a valid European Health Insurance Card (EHIC) - this means your healthcare will not cost extra money, and you’ll be treated just like you are at home.
For all other students, you’ll need to take out some kind of private Spanish health insurance. In some countries, including Ecuador, Brazil, Andorra and Chile, you are entitled to free emergency medical care - you just need to have obtained a free certificate from your home nation prior to travelling. We highly recommend you see if your country has a mutual health provision agreement - it could save you buying private health insurance!
Private healthcare could significantly add to your monthly expenses (it’s likely to be several hundreds euros per year) so it’s best to do your research on obtaining private health insurance in Spain before you move.
As a worker in Spain you will pay for social security as part of your income tax. It will be taken directly off your paycheck, and that will act as Spanish health insurance for the duration of your stay. Always speak to your employer directly ahead of time to ensure that you will be covered, as you must have some type of health insurance when you’re out there - generally, your international health insurance (or wherever you’re moving from) will not be much use in Spain.
To register for public insurance, you must go through the social security office nearest to you. You’ll need to fill in an application form and present this alongside your ID. You’ll be given a social security number with which you can register with a GP - then you’re sorted, and good to go!
Of course private health insurance is always an option if you prefer, but this will be more expensive, so it’s a personal decision for you to make.