How do you get cervical cnacer if you only had sex with your husband your whole life?

Viral infection. Most cases associated with viral infection (hpv-human papilloma virus), causes warts. Some strains high risk for cancer causing. Many cases hpv are "under the radar", subclinical, i.e. No obvious lesion (abnormality); thus can be spread unknowingly by sex partners. If both partners never ever had sex (genital, oral, anal) with anyone else, then the above: unusual; otherwise, can happen. Get paps.
It is possible. Your husband likely contracted the hpv virus that causes cervical cancer from a previous sexual partner, and subsequently transmitted the virus to you. This could have happened many years before your relationship.