There are vents up under the dash that open and close (or supposed to close) with vacuum. When you switch the heater control to vent it sends a vacuum signal to open the door that goes to the passenger side, and a cable does the door on the drivers side. Sometimes the cable gets rusty and sticks open a little, and this lets the rain in.
The rain is going into the vent on the cowl, and running into the heater.
You can check the vent drain tube which is located in the engine compartment, on the firewall just to the passenger side of the motor. Comes out of the firewall and points down toward the starter. It's about 1.5" in diameter black tube. Sometimes it gets clogged with mud or debris.
'87 YJ, 4.2L built and bored, 8.5" of lift, 8.8 rear, AX15/NP 231, Tom Woods drive shafts, Flat fenders, 12,000LB winch, Custom bumpers, Rattle can paint job. Never completed...