Because they have different kinds of brake pads that are optimized for all-weather performance rather than best dry coefficient of friction (this necessitates higher mechanical advantage to have more clamping force), because they have less heat capacity, and because the disc is further away from the road than a rim.
The heat capacity of rims is large. A rim weighs often more than half a kilogram, and transfers some of its heat to the tire as well. When braking, the heat generation is not at such a high level that the rim would immediately heat to the boiling temperature of water. I suspect that when starting to brake, during the first rotation of the rim the brake pads work like a squeegee, removing all but a thin film of water from the rim. At the second rotation of the rim, the localized heating evaporates away the thin water film. At the third rotation of the rim, you have full braking force.
The rim is very close to the road, thus it is likely to get wet from splash water. A disc brake disc, not so much.
Good rims are made from aluminum because (among other reasons) aluminum is soft, so the brake pads do not "polish" the rim like they would do for a steel rim, but instead cause it to wear faster, resulting in a rough structure. The rough structure is what helps with wet braking.
Even if the brake disc is wet from splash water, the different kinds of brake pads not made from rubber have a smaller difference in coefficient of friction between wet and dry states.
Also, if you brake often, you will have discs that are boiling hot (example: 100 kg rider braking at 0.67 g creates about 1400 joules of energy per wheel revolution, and 0.12 kg steel brake disc stores 55.2 joules per degree Celsius, so going from 20 C to 100 C requires only about three wheel rotations with braking). The heat capacity of those small discs is not substantial, and the heat dissipation is not efficient either: the discs being small compared to the rims. If a splash of water hits a boiling hot brake disc, it evaporates immediately.
In a certain sense, the rim brake is the best possible disc brake, having the largest possible disc size, and reusing an existing component as the brake disc. However, a practical rim brake must track a wavy rim to allow riding home after a spoke-damaging accident, so the rim brakes are restricted to simple mechanical devices, and thus, they have low mechanical advantage and thus must use brake pads that have a huge difference in dry and wet coefficients of friction in order to get the best possible dry coefficient of friction. Also, the largest possible disc size increases the risk of the discs being wet from splash water.