Artwork that hung for centuries at St John’s Almshouse in Sherborne will be sold to raise funds for social housing