It took me a while to understand how the 'kit glass' zoom, in my case, an EF-S 18-135 f3.5-5.6 would take so long to focus in dim light situations. I could even hear it 'hunting' to focus, on occassion. I'd often be zoomed in the 100-135mm end of the range and at f5.6, the maximum aperture at that focal length, very little light was passing through the lens for focusing.
When we humans, or any animals, go from a brighter lit area to dimly lit area, the pupils of our eyes get larger to let in more light so we can see as best as possible. Digital cameras, on the other hand, have their aperture (pupil) 'wide open' all the time, until we press the shutter, when it will instantaneously 'stop down' to whatever smaller size it is commanded to do by the camera. But when 'wide open' is comparatively small, such as f5.6, it's like wearing sunglasses outdoors at night with only a street light for lighting. Our eyes 'struggle' to see (and to focus) what is out there. The focus mechanism of a camera likewise has to struggle to not only select what to focus on, but to check/adjust/check/adjust that focus until it is right. "Faster" lenses (small f-stop numbers = larger aperture (pupil) effectively removes the 'sun glasses' and the camera can focus more easily.
Faster glass, lenses with f2.8 or smaller f-stop numbers, let in more more light making focusing easier for the camera. As noted above, the wider apertures also give a smaller depth of field, so it's made even easier to focus. The downside, however, is fast glass gets expensive.