For context, in case anyone is curious, “The landlord shouted to them to leave him alone, for he had already told them that he was mad, and as a madman he would not be accountable even if he killed them all” (p. 31). And similar sentences are written throughout the novel.
I just find it remarkable that (if this is indeed true) in the early 1600s, the Spanish legal system not only recognizes mentally not alright people but also find that even in serious cases such as murder, that they may not be culpable in their actions. Or is this a case of Cervantes employing some sort of satire/joke/exaggeration that just flew over my head and this isn't actually the case?
It is indeed real and not a joke. It had been codified into law in the second half of the 13th century when King Alfonso X the Wise compiled the "Siete Partidas" (Seven Part Code). That code was still the law of the land in the 17th century, and it was quite complete, to be honest. To put it shortly, the Siete Partidas was a general code containing civil, criminal, and administrative laws, which is quite a remarkable feat for the time.
There, in the 1st Partida, title I, law XXI, you can find a general description of the law and the codification of the classic principle that "ignorantia legis non excusat" (ignorance of the law is not an excuse). However, there are a number of exceptions to that principle enumerated in the next law.
Those exempt from responsibility are the mad men who don't know what they are doing (locos cuya locura les impide saber lo que hacen), those lacking memories (desmemoriados), and those under the age of fourteen, even for sexual trespasses. It is underatood in that law the people under those categories lack sufficient judgement or discernment to understand the legal or moral implications of their actions.
Those who are mad enough to not know what they are doing is what we would call insane, id est lacking sanity. The "desmemoriados" are what we would ordinarily call people suffering from dementia, which in this case would exempt them from responsibility as they are not in any mental capacity to situate themselves within the circumstances surrounding them. As for the underage, it is a general concept of lacking sufficient maturity.
So long story short, Cervantes was perfectly aware of the legal matter on which he was commenting.