Your camera is not broken.
The visible moving part is an IR-Cut filter and is designed to float freely when not in use.
During the day, the camera uses the IR-Cut filter to filter out IR light ( fully covering the lens) So it does not distort the colors of images as the human eye sees them.
When the camera is in night mode, the IR-Cut filter is removed, allowing the camera to work fully in the dark.