Packet filtering is a firewall function that examines each incoming and outgoing packet of data and determines whether to allow or drop it based on predefined rules. It helps prevent malicious traffic from entering the network and enhances network security.