Just as humans can smell the air and detect rain when it's close by, dogs have amazing noses so they can smell rain from a longer distance.
The smell of ozone in the air from lightening and the way other scents hang in the humidity before a storm are all signals to your dog that something is on the way.