The perception of the importance of animal health and its relationship with biosecurity has increased in recent years with the emergence and re-emergence of several diseases difficult to control. This is particularly evident in the case of pig farming as shown by the recent episodes of African swine fever or porcine epidemic diarrhoea. Moreover, a better biosecurity may help to improve productivity and may contribute to reducing the use of antibiotics. Biosecurity can be defined as the application of measures aimed to reduce the probability of the introduction (external biosecurity) and further spread of pathogens within the farm (internal biosecurity). Thus, the key idea is to avoid transmission, either between farms or within the farm. This implies knowledge of the epidemiology of the diseases to be avoided that is not always available, but since ways of transmission of pathogens are limited to a few, it is possible to implement effective actions even with some gaps in our knowledge on a given disease. For the effective design of a biosecurity program, veterinarians must know how diseases are transmitted, the risks and their importance, which mitigation measures are thought to be more effective and how to evaluate the biosecurity and its improvements. This review provides a source of information on external and internal biosecurity measures that reduce risks in swine production and the relationship between these measures and the epidemiology of the main diseases, as well as a description of some systems available for risk analysis and the assessment of biosecurity. Also, it reviews the factors affecting the successful application of a biosecurity plan in a pig farm.