The process by which the immune system learns to distinguish self from non-self to avoid attacking healthy tissues.