It is established that the planet can only support spice production because it is dry.
Paul says to the Fremen that they must destroy all spice production on Arrakis.
By making it rain, Paul has accomplished the objective he declared.
By inserting this event into the (1984) movie, it provides a logical ending - Paul learns his destiny, seeks a goal, and by movie's end, he's done it. This makes the movie a self-contained story.
Compare to Star Wars (1977). The very first movie ends with the destruction of the Death Star - a nice neat happy ending which doesn't call for a sequel. Obviously, its commercial success demanded sequels. Empire Strikes Back (1980) ends almost abruptly because it is a given that another installment is to come. Return of the Jedi (1983) again ends with a happy ending to properly close out the trilogy (no further installments contemplated at the time).
Consider also Back to the Future. The first movie was written as a stand alone, despite the hook ending (and the "To Be Continued" which was added to the home video release). The second movie truly ends in mid-story with Doc in the old west and Marty in the 1950s because parts 2 & 3 were shot together.
The studio probably anticipated that Dune would not do well at the box office, and may have wanted to close the door on the possibility of anyone pitching for sequel, hence the nice tidy (rain)bow on the story.