A mathematical model reveals the influence of population heterogeneity on herd immunity to SARS-CoV-2