In the case of most commercially processed foods, it's contamination during processing and packaging that leads to foodborne illness, not the age of the food. So, even after some time passes, candy should be safe to eat as long as it was properly handled and it remains unopened prior to eating.