Breastfed babies usually have a better immune system and have better immunity to viruses and diseases.
However formula fed babies do still have a pretty good immune system and do have immunity to viruses and diseases but the breastfed baby will usually be healthier and have a better immune system.
Breast Milk is always the best milk for babies for better immune systems as well as brain health and sometimes breastfed babies are smarter in some ways than formula fed babies.
Breast Milk which is the best milk for babies contains things such as proteins, fats, sugars as well as antibodies and probiotics.
Some formulas lack those important things and as a result formula fed babies tend to have weaker immune systems than breastfed babies do.