An estimated 154 million adults, or 75% of the US population, aged ≥20 y drink coffee; 49% drink coffee daily (Loftfield et al., 2016). It's been hypothesized that coffee and/or caffeine initiates a series of pharmacological effects that lead to the relaxation of penile smooth muscle and that subsequently could improve ED (Adebiyi & Adaikan, 2004).
In a study of diabetic rats treated with 10 and 20 mg/kg of caffeine per day, caffeine consumption improved the erectile function of the rats by up-regulating penile cGMP, which causes smooth muscle to relax (Yang et al., 2013).
Analyzing data for 3724 men (≥20 years old) who participated in the National Health and Nutrition Examination Survey, Lopez et al. (2015) found that men who drank 2-3 cups or 3-4 cups of coffee per day were less likely to report ED compared to men who drank less than a cup per day.
In another analysis of 7,298 men aged 40-75 years old who had ED, comparing highest (≥4 cups/day) with lowest (0 cups/day) coffee intake, Lopez et al. (2018) found that long-term coffee intake was not associated with risk of ED.
There is a theory that coffee can possibly pump up testosterone concentrations, thus enhancing blood flow to the penis. For example, Wedick et al., (2012) found that caffeinated coffee significantly increased total testosterone after 4 weeks. However, Lopez et al. (2019) identified no linear relationship between caffeine intake and testosterone levels in the total population.
In any case, it appears that regularly drinking coffee isn't going to negatively impact your sexual function.