Variability of the solar cycle length during the past five centuries and the apparent association with terrestrial climate