The main setting for the novel Harry Potter and the Chamber of Secrets is the Hogwarts School of Witchcraft and Wizardry, Hogwarts for short. It is a magical school for young witches and wizards located somewhere in Scotland, hidden from the world of muggles by powerful spells and therefore impossible to locate precisely.
On a larger scale, the setting of the second novel in the Harry Potter series is the whole magical realm itself. The readers see more of Diagon Alley and other locations that exist beyond the knowledge of muggles.
Setting plays a large role in the novel. Hogwarts Castle is a supernatural place in the sense that it is constantly changing and shifting, meaning that it's very hard to know all its secrets. Throughout the novel series, the people named most likely to know the most about it are Dumbledore, the caretaker Mr. Filch, and the Weasley twins. It's hard to say whether even all of them combined have a total understanding of Hogwarts.
As the events of the novel start to unfold and the mysterious Chamber of Secrets comes to play, setting becomes the main issue of the story. The big question is whether the rumored Chamber is even real—and if it is, where is it? It's said in the novel that since the time of the founders of the school, the castle has been searched numerous times and the Chamber has not been found.
It turns out in the end that the Chamber does exist, and the reason why it's been so impossible to locate is that the people who would be able to find it are very rare. The passage to the Chamber requires a parselmouth (someone who can talk to snakes) to open it. The Chamber eventually turns out to be several miles under the school, possibly even under the school lake. As with a lot of Hogwarts locations, it's difficult to pinpoint exactly.
Concerning the main story, the Chamber of Secrets is one of the first locations introduced that requires particular people or circumstances to be found. It serves to familiarize the readers with the concept, paving the way for other spaces like it—such as the Room of Requirement—later in the series.