Content encoding is a process used to compress data for efficient transmission over networks, reducing file size and improving loading times. It plays a crucial role in web performance optimization by encoding web content in formats like gzip or Brotli, which are then decoded by the client browser.