Which chronic illnesses can affect fertility, and why?

It depends. There are a wide variety of chronic illnesses that are common. Some affect fertility, while others do not. It is probably best for you to specify the illness of interest to you in order to get a reasonable answer in this setting where there is limited space.