The idea of making a bag that would keep the pizza hot for as long as it remains in it is built on the possibility of creating an isolated system. Once an isolated system is created, the first law guarantees that the energy (heat is a form of energy) will remain constant inside the system, which means whatever is in the bag will have a constant temperature, since temperature is a measure of heat.
Another way to phrase the first law of thermodynamics is: "energy can neither be created nor destroyed," given that the isolated system is one that does not allow energy nor matter to cross its boundary it is easy to see how an isolated system can keep its temperature constant.
Another way to put it is that energy's ability to do work always decreases. In terms of heat, work is done by heat's transition, and so for the energy's ability to do work to decrease (i.e. for entropy to increase) the systems would reach their maximum entropy when they have the same temperature, which would mean that they will no longer be able to exchange heat between them and therefore would not be able to do work.
As isolated systems, the pizza bag's entropy increases, however the pizza bag and the surroundings together have an entropy that does not increase, this does not violate the second law of thermodynamics since it states that only entropy of an isolated system can increas