Why Are the Devils Locked up in Ramadan?
Question

Why are the devils chained up during the month of Ramadan?
Praise be to Allah.Are the devils locked up in Ramadan?
The chaining up of the devils in Ramadan is proven in a number of hadiths, including the following.
Abu Hurayrah (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “When Ramadan begins, the gates of Paradise are opened and the gates of Hell are closed, and the devils are put in chains.” (Narrated by al-Bukhari, 3277) and Muslim, 1079)
According to a version narrated by Muslim, “the devils are chained up.”
Another such report is the hadith of Abu Hurayrah (may Allah be pleased with him) who said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “When the first night of Ramadan comes, the devils and mischievous jinn are chained up, and the gates of Hell are closed, and none of its gates are opened. The gates of Paradise are opened and none of its gates are closed …” (Narrated by at-Tirmidhi (682) and Ibn Majah (1642). It was classed as hasan by al-Albani in Sahih al-Jami‘ (759)
If the devils are chained up, why do we see evils and sins happening in Ramadan?
With regard to the opening of the gates of Paradise in Ramadan, the closing of the gates of Hell, and the chaining up of the devils , the correct view is that it is to be interpreted in a true sense, which is the apparent meaning of the hadith, and that the gates of Paradise are opened in a real sense in Ramadan, and the gates of Hell are closed, and the devils are put in chains.
The basic principle is that words are to be interpreted in accordance with their apparent meaning and in a real sense, unless there is evidence to suggest that they should be understood in a manner other than the apparent meaning.
Shaykh Taqiy ad-Din Ibrahim ibn Muflih (may Allah have mercy on him) said: 
“The devils are put in chains and shackled in Ramadan, according to the apparent meaning of the hadith. Or it may be that what is meant is the mischievous devils, as was stated by Abu Hatim and other scholars. That does not mean that no evil is committed at all; rather evil is reduced, because they are weakened. Imam Ahmad also interpreted this according to the apparent meaning. ‘Abdullah ibn al-Imam Ahmad said: I said to my father: We sometimes see the majnun [person who is possessed by jinn] having fits during the month of Ramadan.
He said: This is what the hadith says, and there is no need to argue about it.
Ahmad’s approach was that the hadith was not to be interpreted in a manner other than its apparent meaning, unless the early generations (salaf) interpreted it in a manner other than its apparent meaning; so long as that did not happen, it is not to be done.” (Masaib al-Insan min Makaid ash-Shaytan, p. 144)
Ibn al-Mulaqqin (may Allah have mercy on him) said: 
“The gates of Paradise are opened”… this is to be understood in a real sense, as is the rest of the hadith… we have noted above that it [i.e., the chaining up of the devils ] is something real; they are put in chains and their harm and whispers are reduced, and their mischief is not at the same level as in months other than Ramadan.
What confirms the idea that the devils and mischievous jinn are shackled is the fact that, with the beginning of Ramadan, the sinners start to do acts of worship and obedience, and stay away from what they were doing of following whims and desires, and this is clear proof.” (At-Tawdih li Sharh al-Jami‘ as-Sahih, 13/56)
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) was asked: With regard to the days of Ramadan, the Messenger (blessings and peace of Allah be upon him) said, “in it the devils are chained up,” yet despite that we see some people having fits [which are attributed by some to the influence of the jinn or devils] during the day in Ramadan. How can it be that the devils are chained up yet some people have fits?
He replied: 
“According to some hadith reports, the mischievous devils are chained up or shackled . This is according to an-Nasai. Such hadiths speak of matters of the unseen, concerning which our attitude is to accept and believe, but we should not try to discuss it any further. That is more prudent in order to maintain our religious commitment and is better in consequences. Hence, when ‘Abdullah ibn al-Imam Ahmad said to his father: Some people may have fits in Ramadan, the Imam said: This is what the hadith says, and there is no need to discuss the matter further. Moreover, the apparent meaning indicates that the devils are chained up and prevented from tempting people, based on the fact that there is much good and much turning to Allah, may He be exalted, in Ramadan.” (Majmu‘ Fatawa Ibn ‘Uthaymin, 20/75)
Based on that, the chaining up of the devils is chaining in a real sense, and Allah knows best about it. It does not mean that the devils have no impact at all, or that no one will have fits or be affected by the devils and the like, or that no sins will occur among people.
Rather what is meant is that they are weakened in Ramadan, and are not able to do what they are able to do in months other than Ramadan. Imam Abul-'Abbas al-Qurtubi (may Allah have mercy on him) said: If it is said, we often see evils and sins happening in Ramadan ; if the devils were chained up no evil would happen,
This may be answered from several angles:

They are only shackled and restrained from those who observe the fast, fulfilling the necessary conditions and adhering to the appropriate etiquette. As for those who do not observe the fast in the proper manner, the Shaytan is not restrained from them.
If we assume that they are chained up and kept away from every person who fasts, that does not necessarily mean that all the devils are chained up and no evil will happen, because there are other causes for the occurrence of evil, other than the devils, such as evil souls, bad customs and traditions, and the devils among mankind.
This is speaking of most of the devils and the mischievous ones among them; as for those who are not described as mischievous, they may not be chained up.

What is meant is that evil is reduced, and this does indeed happen during the month of Ramadan, because the incidence of evil and shameful deeds during this month is little compared to other months.” (Al-Mufhim lima Ushkila min Talkhis Kitab Muslim, 3/136)
Why are devils chained up in Ramadan?
The scholars have mentioned the wisdom behind the chaining up of the devils during Ramadan: it is to reduce their evil and their ability to tempt people, and to prevent them from harming and disturbing the Muslims and spoiling their fast; and so that they will not do what they do at times other than Ramadan, such as misleading people away from the truth, and diverting them from goodness. That is so that people can focus on doing acts of worship and obedience and keep away from sins and whims and desires during the month of Ramadan.
Shaykh al-Islam Ibn Taymiyah (may Allah have mercy on him) said: 
“That is only because in the month of Ramadan, people are motivated to do good and righteous deeds, through which and because of which the gates of Paradise are opened, and they are discouraged from doing evil, because of which the gates of Hell are closed. The devils are chained up, so they are not able to do what they usually do when people are not fasting, for the one who is chained up is restricted, and they are only able to gain control over the sons of Adam because of whims and desires, so if people refrain from whims and desires, the devils are chained up.” (Majmu‘ al-Fatawa, 14/167)
He also said:
“Hence the Prophet (blessings and peace of Allah be upon him) said: “When Ramadan begins, the gates of Paradise are opened and the gates of Hell are closed, and the devils are chained up.” The channel through which the devils flow, which is the bloodstream, is restricted, and when it is restricted, people are motivated to do good deeds, because of which the gates of Paradise are opened, and they are motivated to refrain from evil deeds, because of which the gates of Hell are opened. The devils are chained up, and their strength and influence is weakened as a result of their being chained up, so they are not able to do during the month of Ramadan what they do at other times. He did not say that they are killed or that they die; rather he said that they are chained up, and the devil who is chained up can still do harm, but it is less and weaker than it may be at times other than Ramadan. It depends on how perfect or otherwise the fast is; if a person’s fast is perfect, then the Shaytan is warded off in a manner that does not happen in the case of an imperfect fast.” (Majmu‘ al-Fatawa, 25/246)
Al-Hafiz Ibn Hajar (may Allah have mercy on him) said:
“It was said: This indicates that the accountable adult has no excuse. It is as if it is said to him: "The devils are restrained from you, so do not blame them for your failing to do acts of worship and obedience or for your doing acts of disobedience.” (Fath al-Bari by Ibn Hajar, 4/114)
Shaykh Ibn ‘Uthaymin (may Allah have mercy on him) said:
“This is a way in which Allah helps the Muslims, for He restrains their enemy who calls his party to be among the people of the Blazing Fire. Hence you will find among the righteous the desire to do good and refrain from evil during this month more than at other times.” (Majalis Shahr Ramadan by Ibn ‘Uthaymin, p. 8) (See also: Sharh Sahih al-Bukhari, by Ibn Battal (4/20); Ikmal al-Mu‘lim bi Fawaid Muslim by al-Qadi ‘Iyad (4/5); al-Mufhim by Abu’l-‘Abbas al-Qurtubi (3/136); at-Tawdih li Sharh al-Jami‘ as-Sahih by Ibn Mulaqqin (13/56); Mirqat al-Mafatih by al-Mulla ‘Ali al-Qari (4/1364); at-Tanwir Sharh al-Jami‘ as-Saghir by as-San‘ani (2/41)
And Allah knows best.