بسم الله الرحمن الرحيم
In the Name of Allah most Gracious most Merciful
The purpose of vaccines is to help improve immunity towards an illness/disease, vaccination introduces a weakened pathogen so that when the immune system encounters the disease that was vaccinated from, it would recognize it and destroy the microorganisms. Basically, vaccines are intended to protect from an illness/disease, and that alone is ok. An example would be what was narrated by Bukari, that the Prophet (Peace and blessings be upon him) said:
مَنِ اصْطَبَحَ بِسَبْعِ تَمَرَاتٍ عَجْوَةٍ لَمْ يَضُرَّهُ ذَلِكَ الْيَوْمَ سَمٌّ وَلاَ سِحْرٌ
Whoever eats seven ‘Ajwa dates in the morning will not be effected by magic or poison on that day
But Issues may come because of the chemicals and byproducts (Substances) in a vaccine. So the ruling of a vaccine depends on (the ruling of) the substance used in the vaccine. They are of different types (The following is derived from question no.159845 from IslamQA) :
- Substances which are halal to use, and have beneficial effects. Such vaccines are halal to be used.
- Substances which are halal to be used, but cause more harm then good to the body. Such vaccines are haram.
- Substances which were originally haram but through Istihalah became halal, such vaccinations are permissible because the transformation that changed the substance also changed the ruling in regards to it.
- The fourth category includes all substances which are harmful or haram , or there is uncertainty in regards to the effects, or there is difference of opinion among doctors and specialist in regards to its benefit. Such vaccines are haram.
There is no problem with being vaccinated if an epidemic is feared. The necessity or requirement of being vaccinated is secondary (In Ruling) after seeking treatment (التداوي).
If you have any questions in regards to this subject, then I invite you to ask them here.
سبحان رب العزة عما يصفون، و سلام على المرسلين و الحمد لله رب العالمين