Riva, Palazzo San Francesco: da chiesa a convento fino a diventare caserma