There is no evidence that the founders actually built Hogwarts Castle, and the castle was not purpose built to house a school (Hogwarts: the Castle). However we do know from the sorting hat that one founder did build something that would become incorporated into the modern day castle: the Chamber of Secrets.
The myths surrounding the Chamber of Secrets are contradictory and nonsensical, just like the information we have about Slytherin himself. Although legends say Slytherin left a monster to purge the school of muggleborns, the basilisk itself is an indiscriminent weapon and harmful to the entire school. When it was unleashed Hogwarts was nearly closed down twice. Even if we believe all that is said about Slytherin, there is no doubt that he loved the school he had helped create. Therefore it is more likely that the Chamber of Secrets and the basilisk within was placed there for an entirely different reason.
The Master Architect
In Hogwarts: a founding, I explained that the four founders were not professional educators but rather master tradesmen, and they taught their students tradecraft through vocational training. They did set up a school, but rather four different apprenticeship schemes. The sorting criteria for each “house” was directly related to the type of trade each founder was engaged in. They chose to set up their enterprises in an already flourishing magical town, which happened to be called Hogwarts.
I have explored in Hogwarts: an Evolution that we have no reliable information about Slytherin at all. Slytherin left Hogwarts before the sorting hat was made, and what we think of as the core ethos of Slytherin house is heavily (or entirely) influenced by the views of his successors. Therefore it is very hard to speculate about what trade Slytherin was actually engaged in, or if he really enjoyed the Dark Arts and hated muggleborns.
However the one thing we do know is that Slytherin built the chamber of secrets and left a basilisk inside (which he presumably hatched himself).
I would postulate that Slytherin was probably a master architect, given the complexities of the chamber he built. Part of his job was to strengthen and fortify defences of Hogwarts town before the castle itself was built. He probably also had mundane tasks like erecting barns/houses and building magical bridges across gorges. If Slytherin was an architect, it seems rather strange that he would have gained a reputation for dabbling in the Dark Arts which are mostly offensive magic. Gryffindor, who was the resident adventurer/dragon slayer, would have had more use for the Dark Arts.
However I have explained in Hogwarts: a Founding, that the hill on which Hogwarts is built is most likely a source of ancient magic, which is what attracted magical peoples to settle in that area millennia ago. The ancient magic must have provided the early settlers with defence and maybe even offense when harness correctly. The magical protections on Hogwarts Castle, which Dumbledore alludes to, probably have roots in this ancient magical source.
It is likely that by the time of the founders in the late Dark Ages, man-made fortifications had taken the place of the ancient magical source in protecting Hogwarts Town and people had forgotten how to harness the ancient energies. Slytherin may have encountered this ancient magic when he was digging down to build foundations or repairing ancient defensive structures.
I believe Slytherin made it his life’s work to rediscover the use of this ancient magic.
The Final Resting Place
Like many traditional legends about ancient magic – this source was buried deep underground, very much like the Veil in the Department of Mysteries. The Chamber of Secrets was built by Slytherin to be his laboratory/work station/excavation site. However Slytherin probably also intended the Chamber to eventually serve as his final resting place. The descriptions in book give off the impression that the underground chamber was similar in essence to a tomb. The fact that Slytherin chose to adorned the chamber with his own face, suggest that he wanted future visitors to have no doubt who rested here.
If Slytherin had intended for the Chamber to also be his final resting place, the existence of the basilisks makes much more sense. The basilisk, indiscriminant with its deadly gaze, is much more effective at defending a large area than attacking specific targets. Slytherin left it there to protect his tomb and all the knowledge he had accumulated during his life time. He did not want the powerful knowledge of the ancient magic he had discovered to be accessible to everyone but other parselmouths, inevitably members of his own family, would be able to enter and learn the secrets within.
It is likely that after Slytherin’s departure, people did attempt to enter the Chamber and fell foul of his basilisk. This is where the legends focusing on Slytherin’s monster come from.
The Great Strife
I believe what Slytherin discovered deep underground was very powerful and potentially very destructive source of ancient magic. We do not know exactly what his contemporaries thought of his discoveries, but people tend to fear what they don’t understand and it is not farfetched to believe that more ignorant people branded it was Dark Magic. Even if people did not fear the ancient power source, even the other founders would have been uncomfortable with the idea that Slytherin was in sole control of this resource.
We know that there was a time of a great strife leading up to Slytherin’s abrupt departure from the sorting hat song in HBP.
“So Hogwarts worked in harmony
for several happy years,
but then discord crept among us
feeding on our faults and fears.
The Houses that, like pillars four
had once held up our school
now turned upon each other and
divided, sought to rule.”
This discord most likely relates to a disagreement between the founders over what should be done with the ancient source of magic under Hogwarts. I believe one or more founders wanted to harness this ancient magic not just to protect Hogwarts but also in a more aggressive manner, perhaps as a weapon of mass destruction against invading hordes. As I have discussed in Hogwarts: a Founding, the founders lived at a time of great violence and chaos. Hogwarts was under threat from Viking raids and infighting between Scottish tribes.
Gryffindor, the brave, was most likely Hogwart’s resident chief protector/monster slayer and also the most likely candidate for wanting to use the ancient source of magic aggressively. In contrast we can see from the sheer amount of effort Slytherin put into building the Chamber and hatching a basilisk that Slytherin specifically wanted to protect the source and severely limit access to this ancient course of magic. Slytherin may have been cunning and ambitious but he was not foolhardy and aggressive (those of the typical pitfalls of a Gryffindor). He probably had a very good grasp of just how terribly destructive this power could be, and thus did not want to use it in the way Gryffindor intended.
The hat’s song clearly states the strife involved all the founders fighting for supremacy and not a case of three against one. Clearly both Ravenclaw and Hufflepuff also had their own plans for Slytherin’s discovery and they most likely added fuel to the fire of Slytherin and Gryffindor’s original disagreement. However it was Slytherin who made the ultimate sacrifice of leaving the school.
“And at last there came a morning
when old Slytherin departed
and though the fighting then died out
he left us quite downhearted.
And never since the founders four
were whittled down to three
have the Houses been united
as they once were meant to be”
Many readers have chosen to interpret the above two verses as suggesting Slytherin was the cause of the strife in the first place, and only his absence could have healed the divide.
However it is just as likely that Slytherin consciously chose to leave his life’s work to stop his three friends destroying what they had built together. By physically leaving Hogwarts, Slytherin removed the other founders only method of directly accessing the ancient power, as none of them could get into his chamber and past the basilisk. Thus it put an end to the endless fighting over what the ancient power should be used for.
The loss of Slytherin must have also bought the other three founders together as they had to take over Slytherin’s duties and care for the students he left behind. As I discussed in Hogwarts: an Evolution, Slytherin’s department was a catalyst in unifying the four apprenticeship schemes into what would become one school.
Slytherin’s departure essentially enabled Hogwarts, the school, to be born.