The only way to factor out the biases completely is with a twin study: same mother, same environment. That's what they did with the "Twins Early Development Study." This study found no correlation between breastfeeding and IQ after the age of 2.
"In this particular study, we cannot reject the possibility that breastfeeding could matter in either direction—that it could decrease or increase respiratory infections. What we can say is that the data doesn’t support the claim of a reduction in respiratory infections as a result of breastfeeding."
"These researchers have continued to follow the children in the trial through the age of seven. They find no evidence of any long-term health impacts: no change in allergies or asthma, cavities, height, blood pressure, weight, or indicators for being overweight or obese."
Quotes from Crib sheet by Emily Oster. On the other hand, one compelling reason to breastfeed is for the mother, not the child. Breastfeeding lowers risk of breast cancer.
Can you accurately predict which ones in the class were breastfed versus formula fed given all information (excluding their feeding)?
If you ask teachers the answer is you cannot.