The wp_nav_menu() function in WordPress is used to display a navigation menu in a theme. It allows you to create menus and assign them to specific locations in your theme.