Everyone must have medical assistance in Spain, either from the Spanish Social Security, which is free, or from a private insurance company. If you are from a country in Europe you can qualify for Social Security Services.
Holidaymakers from Europe must bring their blue European Card from their country for emergency medical assistance.
However if you decide to relocate to Spain and become a resident then this card will not be sufficient, as a resident you can benefit from all of the Spanish Social Security Services.
If you are a pensioner you need to make sure that you get the E-121 form from your home country. This you should take to your local Social Security office.
If you are not a pensioner you need to pay monthly fees. If you work in your own business you must register with your local office. Once done you should set up a direct debit for the monthly payments to be taken from your bank account.
For both of these options you will need to have a good level of Spanish to fill in the forms and to talk to the workers in the office, alternatively you can get a Consultant (Asesoría) to do it for you. This option will save you time and in my experience the cost of a Consultant is not too high. You will need copies of your Residents Card or Certificate and your NIE number. In due course the card will be sent to your address so that you can present it when you make an appointment with a doctor or if you have to go to hospital.
If you work as an employee your employer will arrange this for you.
If you have children then you will need to get them a card as well, you can apply for a child or children at the same time as applying for yourself – the Social Security numbers for your children are then associated to your card and your payments cover them.
You should remember to carry your card with you as you will need it whenever you make a medical appointment or want treatment at a hospital – do make a note of the numbers in case of loss!