In the first two Jurassic Park films directed by Spielberg, we witness that the Dinosaur always attacks at night with the rainy weather. Particularly if the T-rex is the main dinosaur of the film you know that is going to happen. Is there a reason why the T-rex attack at that specific time and weather? Did the writers or Steven Spielberg explains this in the commentary?
The scene for the first movie at least is a mixture of Animatronics and CGI. CGI being used for whole body shots.
By setting the scene at night in the rain with few light sources, it made the job of rendering the CGI T-Rex much easier. The movie broke new ground in CGI animation but the used tricks like this to make the end-result look much more realistic than they could have achieved otherwise at the time.
For more information you can read more about it in this Screenrant Article.
As @Flater points out, the lighting conditions and rain also make the Animatronic look more real too.
The storm is both a plot device and fairly inspired artistic and directorial decision. The conditions make the scene tense and claustrophobic as well as making the effects more realistic.