My favorite appearance of RPGs in the media is a tie between the Community AD&D episode and the old film Cloak and Dagger. The Community episode made some great jokes about D&D and gamers while still unabashedly showing its love for D&D. The jokes about Chang in Drow makeup are hilarious, and the episode just keeps getting funnier from there.
Cloak and Dagger is a film that I saw as a kid. It opens with a boy playing a secret agent role playing game. What really struck me about this film was that the rpg portrayed in the film wasn’t a fantasy game. Role playing is synonymous with the fantasy genre for so many people, and seeing a movie show a spy rpg was groundbreaking to my childhood brain. Also, I loved the scene where the main character is attacked by giant polyhedral dice.
I feel that I need to add the movie Astropia for honorable mention. I watched this on Netflix one night. The best way to describe it is that it is an Icelandic romantic comedy where a girl ends up taking a job in a game store and finds true love in a D&D group. Definitely a movie I never thought would ever exist!