Dual role of delay effects in a tumour–immune system