While the best transfusion option is always the same blood group, this is not always possible.
The O group (universal donor) is called so because of its ability to be transfused into a person with any other blood group.
Since the unit that is being transfused is generally much smaller than the person's actual blood volume, the presence of anti-A and anti-B antibodies in the O blood group is insufficient to cause a severe immunological reaction in the recipient.