When marshmallows are roasted, heat transfer through radiation causes a chemical change. The sugar undergoes caramelization and Maillard reactions, producing water molecules that evaporate and leave carbon behind, resulting in a blackened, crispy exterior. This combination of chemical reactions gives roasted marshmallows their distinctive flavor and texture.