Because when a sealed container is heated, the contents inside can expand as they warm up. If the container is completely sealed without any way for the expanding air or gases to escape, it can lead to a dangerous increase in pressure. This pressure buildup can cause the container to explode or rupture, leading to potential injuries and making a mess.
Note:
Do not heat liquid or food in a sealed since it may explode. For instance, food in feeding bottles, baby food jars, canned food, eggs in their shell and whole hard-boiled eggs.