Rear bulbs, front headlight question

Can anyone let me know how to take off the bracket to the rear bulb housing connecting the wires.
I can't work out how to get it off. Here is a photo of the front.

A part has broken off my front headlight, but strangely, everything seems to work fine.
Can anyone let me know what this is for?
See photos.

Thank you