The boys discover the castle in chapter 6 of Lord of the Flies.
When the boys are building sand castles on the beach they notice a strange rock that they have never seen before. Ralph points it out during the discussion of whether or not they can get rescued.
But instead of this a narrow ledge of rock, a few yards wide and perhaps fifteen long, continued the island out into the sea. There lay another of those pieces of pink squareness that underlay the structure of the island. (ch 6, p. 148)
The castle represents another chance for the boys, but it is also another turning point. It is a test of Ralph’s leadership.
Ralph dismissed Simon and returned to his personal hell. They would reach the castle some time; and the chief would have to go forward. . (ch 6, p. 148)
Castle Rock is an island connected to the main island by a bridge. Jack is instantly enamored of the rock, and sees its value as a fort. Ralph is not impressed. Jack will take advantage of his militaristic attitude later to seize power from Ralph. Jack is much more savage than Ralph, and the tide is turning on the island.
In chapter 1, when Ralph, Jack, and Simon leave to explore and find out whether they are on an island or not, they see castle rock when they reach the top of the mountain, as the following extract illustrates:
There, where the island petered out in water, was another island; a rock, almost detached, standing like a fort, facing them across the green with one bold, pink bastion.
However, the boys only explore the area later, in chapter 6, when they go searching for the beast. It is evident that the boys are already aware of castle rock's existence at this point because Ralph and Jack speak about it even before they go there. Ralph refers to it as a castle because, as the above extract indicates, it stood out "like a fort." It is also evident that Jack has been close to castle rock. In chapter 6, when the boys decide to hunt down what they believe is the beast, Ralph asks him:
“Now think, Jack. Is there anywhere on the island you haven’t been?”
Unwillingly Jack answered. “There’s only—but of course! You remember? The tail-end part, where the rocks are all piled up. I’ve been near there. The rock makes a sort of bridge. There’s only one way up.”
When the boys finally reach castle rock, Ralph is the first to sidle up against its side by using the ledge. Jack soon follows him and is impressed by what he sees. He remarks:
“What a place for a fort!”
Ralph, though, is not much inspired and states, "This is a rotten place.” Ralph believes that the place has too little water or any other sustenance, for that matter, while Jack is focused on protection and the fun element of having a stronghold.
Their conversation is another example of the contrast between the two boys. This difference of opinion is what eventually leads to the break-up of the group. When Jack later establishes his own group, they make this area their headquarters. It is not easily accessible and can be defended from intruders by rolling boulders down the sides of the fortress onto anyone who dares to approach. Jack indicates his excitement about this possibility when he exclaims:
Shove a palm trunk under that and if an enemy came— look!
His remark foreshadows Piggy's tragic demise later when Roger does what Ralph suggests can be done. In chapter 11, Roger deliberately loosens a large rock and releases it to fall downwards where it smashes into Piggy, throwing him onto the rocks below.