Bits of the ruin you see today of Dunscaith Castle date to the 13th century, but due to its strategic location on the west coast of Skye's Sleat Peninsula, there has been a fort of one kind or the other here for at least a thousand years.
Dunscaith is an intriguing ruin to explore, especially if, like the warrior Cuchulainn, you get onto the rock by crossing the wily Bridge of the Cliff. But not to worry, these days you have an easier time crossing the bridge than Cuchulainn did, as it involves tip-toeing across the ledge of a drawbridge the MacDonald's built a few hundred years later. Here's a view of the bridge from the landward side of the castle-rock.
In my opinion a visit to Dunscaith is one of the most rewarding short hikes in the islands (it's only a quarter-mile from the road). Aside from the history, the views west to Strathaird, and south to the Small Isles, make a visit there worthwhile. For a description of a visit to Dunscaith, see book Book 2, chapter 1. If tip-toeing across the bridge supports sounds boring, you can always try a Cuchulainn salmon-leap. See this RCAHMS page for more on Dunscaith.