While it is true that the various Mosaic law codes - the Ten Commandments, the Book of the Covenant, the Holiness Code, and the various collected laws of the priestly code - have little or nothing to say about long-term incarceration as a punishment for crime, there are scriptural precedents for the judicial practice of imprisonment.
It is interesting to note the progression of the judicial practice of imprisonment from the pre-history of national Israel through the monarchial period down to the post-exilic period.
Detainment until Execution of Judgment
11 The Israelite woman's son blasphemed the Name in a curse. And they brought him to Moses-now his mother's name was Shelomith, daughter of Dibri, of the tribe of Dan- 12 and they put him in custody, until the decision of the Lord should be made clear to them.In both of these cases, incarceration seems to be short-term until a decision on judgment is reached.
Lev. 24:11-12 32
32 When the Israelites were in the wilderness, they found a man gathering sticks on the sabbath day. 33 Those who found him gathering sticks brought him to Moses, Aaron, and to the whole congregation. 34 They put him in custody, because it was not clear what should be done to him.
Incarceration as a King's Prerogative
26 The king of Israel then ordered, "Take Micaiah, and return him to Amon the governor of the city and to Joash the king's son, 27 and say, 'Thus says the king: Put this fellow in prison, and feed him on reduced rations of bread and water until I come in peace.'"In the period of the monarchy - the united and divided kingdoms (1050-586 BCE) - the power to imprison seems to fall to the monarchs as the chief judicial agent in the nation.
I Kings 22:26-27
10 Then Asa was angry with the seer, and put him in the stocks, in prison, for he was in a rage with him because of this. And Asa inflicted cruelties on some of the people at the same time.
II Chron. 16:10
15 The officials were enraged at Jeremiah, and they beat him and imprisoned him in the house of the secretary Jonathan, for it had been made a prison. 16 Thus Jeremiah was put in the cistern house, in the cells, and remained there many days.
4 Then the officials said to the king, "This man ought to be put to death, because he is discouraging the soldiers who are left in this city, and all the people, by speaking such words to them. For this man is not seeking the welfare of this people, but their harm." 5 King Zedekiah said, "Here he is; he is in your hands; for the king is powerless against you." 6 So they took Jeremiah and threw him into the cistern of Malchiah, the king's son, which was in the court of the guard, letting Jeremiah down by ropes. Now there was no water in the cistern, but only mud, and Jeremiah sank in the mud.
Incarceration as Power of the Courts
25 "And you, Ezra, according to the God-given wisdom you possess, appoint magistrates and judges who may judge all the people in the province Beyond the River who know the laws of your God; and you shall teach those who do not know them. 26 All who will not obey the law of your God and the law of the king, let judgment be strictly executed on them, whether for death or for banishment or for confiscation of their goods or for imprisonment."In the aftermath of the exile and return, the administration of justice seems to fall to an independent judiciary that had the power to (1) impose the death penalty, (2) banish from the nation, (3) confiscate property, and/or (4) imprison the perpetrator.
See the article on "Imprisonment" at the Jewish Virtual Library for a more detailed study of this issue.
It is perhaps best to understand the progression of Hebrew notions of punishment and imprisonment against the backdrop of the rise of Israel as a nation state with the attendant rationalization and bureaucratization of laws and institutions that necessarily followed this advance. The more primitive policies reflect tribal organizations - extended families led by a patriarch - only loosely tied together in a confederation by common devotion to YHWH. Only with the rise and maturing of the centralized state was full police power granted to governmental institutions.
As a parting thought, a few questions remain. Even though imprisonment appears to be part of the judicial process of ancient Israel, did this practice ever reach the proportion and extremes of modern long-term prison penalties? Were the motives for incarceration the same as the modern motives of deterrence and rehabilitation?