The purpose of the light inside a microwave is primarily for illumination, allowing you to see the contents of the microwave while it is in operation. The light helps you monitor the cooking progress without having to open the door and interrupt the cooking cycle.
Regarding the light staying on when the microwave is unplugged and turned off, it depends on the specific microwave model. In most cases, the light should not remain on when the microwave is unplugged or turned off. When you unplug the microwave or turn it off, it should cut off power to all components, including the light. However, there may be some microwave models that have a separate circuit or power source for the light, which could potentially keep it on even when the microwave is not in use. To be certain about the behavior of the light in a particular microwave model, it is recommended to consult the user manual or contact the manufacturer for specific information.