Necessity is a defense used in criminal law if you have done something wrong but you did it to protect yourself or others from danger. For example, if someone breaks into a store to take food during a natural disaster because they are really hungry, the court might decide that it was necessary because of the emergency and the person won't be punished.