I don't think a moral lesson has anything to do with film. It can certainly be a part of it, if the creators of the film chose to go down this route, but it's certainly not a prerequisite to producing a film.
In terms of films that appear in the cinema or are created by the "film industry", a film is simply a financial venture - so the chief role of a film in this context is to earn the studio which funded it some money.
Secondary objectives are that it should entertain or perhaps provoke thought or curiosity in an audience as a means of drawing in paying viewers or furthering the reputation of the actors, writers, or film franchise etc...
But even the audience's opinion of a new release is gauged by box office sales, which is essentially a financial transaction.
Obviously, not all films are created to make money. Some are produced at the expense of the film maker, and many amateur films or even YouTube clips could be considered cinematic productions which don't have monetisation as their core objective.
These type of films may have a myriad of purposes behind them: From artistic motivation through to political propaganda.