A crystal ball is used in Divination as a method of fortune telling. The crystal ball is called an ‘orb’ by Professor Trelawney (PA15).
The third years in Divination studied how to use the crystal ball, although nobody in the class seemed to be able to see anything through gazing into the it, with the exception of Professor Trelawney, who claimed to be able to see the Grim in Harry’s ball (PA15). For their Divination exam, the third years had to gaze into the ball and tell Professor Trelawney what they saw (PA16).
During the Battle of Hogwarts, crystal balls were used as a weapon by Professor Trelawney, who threw one at Fenrir Greyback, knocking him out (DH32).
In the film, when Hermione leaves Divination after arguing with Professor Trelawney, she knocks the crystal ball off the table and it rolls out of the classroom. Harry picks it up on his way out of class and when he returns it to Professor Trelawney, she makes the prediction about Peter returning to Voldemort.