Dear Student,
A spore is a tiny, spherical, unicellular structure covered by a thick wall. Spores are formed inside the sporangium by the division of cells. This sac-like structure provides a tough coat covered around the spore that protects it from unfavourable conditions and which is why they survive for longer duration of time.
Bacteria produces spores that are highly resistant structures which can with stand high temperature, UV light, resistance to desiccation, lack of nutrients, etc. Under such unfavourable conditions, bacteria undergoes sporulation.
Regards