Immunodeficiency occurs when one or more parts of the immune system are dysfunctional. It can be primary (genetic) or secondary (acquired). Conditions like HIV/AIDS cause secondary immunodeficiency, making individuals more susceptible to opportunistic infections.