Racing in the rain is random for races in different areas but you should get this rather early on and you'll have plenty of chances to race in the rain.
Obviously you only need to finish a race, not win.
It doesn't matter if its raining in freeroam when you start the race as the race's weather can changeTassadar 1337 Notes that they had to win an event for this to unlock.