Let's first look at the houses. The houses are a class in the buildg layer. Rasters normally only store values, so we need to assign a proper legend to raster layers.
1. In the Layers panel click on the to open the Layer styling panel.
2. Choose Paletted/Unique values as render type. Keep Random as Color ramp type and click Classify.
Use the screenshot below as a reference to add the labels to the class
numbers by double-clicking on each label name. Double-click on the color
to make it more intuitive as shown in the example.
Because buildg is
a discrete raster we used the Paletted/Unique values render type. This
renderer classifies each unique integer value found in the raster layer.