This is because the blood cells have certain molecules sticking out of their surface. Our immune system had many ‘scouts’ which go around looking for cells which shouldn’t be there, and they check if a cell belongs to our body by looking at these molecules. If people have the same blood group, then the scouts assume that the cells are normal and just go about their work. If they have different blood groups, then the scout notices that the molecules are different, and trigger an immune response. Sometime the immune response can be so massive that it causes the patient to die, so it is very important to make sure the blood groups match up.
For a blood transfusion, people must receive a blood type that will not react negatively with their own. If someone receives an incompatible blood type, a ‘hemolytic’ reaction occurs, and death is a possibility. In a hemolytic reaction, kidney failure and shock may happen, and the immune system in the receiver’s blood can attack the transfused blood.
You can check if two blood samples are compatible by doing a ‘cross-matching’ experiment. If the two bloods mixed together form clumps (called ‘agglutination’) then transfusion cannot take place.