Long before rain actually falls, barometric pressure starts dropping, and plenty of insects can sense that shift well before humans ever feel a difference in the air. Ants, spiders, and cockroaches all respond to falling pressure by seeking shelter, which usually means moving indoors toward the nearest dry, stable environment they can find.
This is exactly why pest sightings often spike a day or two before a storm actually hits. The pests aren't reacting to rain that's already fallen; they're responding to atmospheric changes that signal rain is on its way, and your home looks like a far safer bet than staying exposed outside.