Open composer and click on the “add legend” button as shown below.
Once the legend has been added to the map, you can add and remove map layers from the legend as shown below.
You can also add a frame around the legend box and change the background color to improve the visibility of the legend items if necessary.