Is becoming drunk a sin? If yes, is it a Torah prohibition or a rabbinical one? Please give a lot of details. And also sources.
Rambam Hilchos De'os 5:3
וכל המשתכר, הרי זה חוטא ומגונה ומפסיד חכמתו; ואם משתכר בפני עמי הארץ, הרי זה חילל את השם.
Anyone who gets drunk, he is a sinner and is disgusting and loses his wisdom. And if he does so before commoners, he profanes G-d.
According to the Rambam, the mitzvah of simcha on Yom Tov does not encourage or even permit drunkenness (Hilchos Yom Tov 6:20):
כשאדם אוכל ושותה ושמח ברגל, לא יימשך ביין ובשחוק ובקלות ראש ויאמר שכל שיוסיף בזה ירבה במצוה, שהשכרות והשחוק הרבה וקלות הראש, אינה שמחה אלא הוללות וסכלות. ולא נצטווינו על ההוללות והסכלות, אלא על השמחה שיש בה עבודת יוצר הכול, שנאמר "תחת, אשר לא עבדת את ה' אלוהיך, בשמחה, ובטוב לבב" (דברים כח,מז), הא למדת שהעבודה בשמחה. ואי אפשר לעבוד את ה'--לא מתוך שחוק, ולא מתוך קלות ראש, ולא מתוך שכרות.
(Summary) When one eats and drinks and is festive on the Festivals, do not be exceeding in [consumption of] wine ... as drunkenness is not happiness, rather it is vanity and foolishness. The mitzvah on Yom Tov is happiness which has service of the Creator in it... And it is impossible to serve Hashem out of drunkenness.
Drinking on Purim is a specific case in which the direct mitzvah is to get drunk (Rambam Hilchos Megillah 2:15):
ושותה יין, עד שישתכר ויירדם בשכרות.
And drink wine until you get drunk and drift off from your drunkenness
However, even in this case, some opinions understand the Rambam to not be literal, and to just mean that one should drink more than he is accustomed to, get tired from the drinking, and go to sleep (Darkei Moshe O.C. 695:1).
As noted, Rambam writes in Hilkhot De'ot (5:5) that drunkenness is a sin. Furthermore, he writes that drinking in a way that will intoxicate oneself is forbidden:
וכל המשתכר, הרי זה חוטא...ואסור לשתות בצוהריים ואפילו מעט, אלא אם היה בכלל האכילה, שהשתייה שבכלל האכילה אינה משכרת
Anyone who gets drunk is a sinner...And it is forbidden to drink in the afternoon--even a little--unless it is in the course of eating, for drinking that is included in eating does not get one drunk.
Furthermore, he writes in Moreh Nevukhim (3:8):
As for gatherings with a view of drinking intoxicants, you should regard them as more shameful than gatherings of naked people with uncovered private parts who excrete in daylight sitting together.
Although he evidently holds this sin to be very severe, it does not appear that he holds it to be a technical biblical or rabbinic prohibition. He writes in Moreh Nevukhim (3:48):
The reason for nazaritism is most manifest it consists in bringing about abstinence from drinking wine, which has caused the ruin of the ancients and the moderns...The prohibition you see against eating anything that cometh of the grape vine results from the law regarding nazaritizm being an additional measure made with a view to the avoidance of wine, so that people should contend themselves with no more of it than necessary.
Notably, he makes no mention of drunkenness being an actual sin. Rather, he merely writes that the lesson of the nazarite is that we should avoid wine to the degree possible.
In a similar vein, he writes in Hilkhot Nedarim (13:24) that making an oath to never get drunk is a praiseworthy form of serving God. The implication (especially given the juxtaposition to other activities which he similarly praises swearing off) is that drunkenness is not a technical sin.
In this same vein, his son Rabbenu Avraham writes:
If God would forbid everyone to drink wine and alcohol as he forbade non-kosher animals and fowl, not all would be able to comply...such a prohibition would also interfere with the benefit of wine and the occasional need to drink it. And if our Torah would say "Drink but don't become intoxicated," it would not work because there is no precise amount. Therefore he taught in the true Torah that it is permitted...but indicated that drunkenness is repulsive and practically forbidden (Hamaspik L'ovdey Hashem ed. Wincelberg p. 556).
This is in turn paraphrased (unattributed) by Rashba (Shut HaHadashot: 367):
ומפני שלא ראתה התורה למנוע שתית היין ולא יוכל לתת שעור לשתיתו עד שתתיר התורה בדרך משל שתיית הרביעית ותאסור יותר משתיית הרביעית וכיוצא בזה, ספר הכתוב התקלות הנולדות ממנו לתועלת גדולה שיהא זהיר ונזהר ממנו כל איש כפי אשר יכיר כל אחד בטבעו
And since the Torah didn't want to forbid the consumption of wine, and could not give an amount to the drinking, such that the Torah would for example permit the consumption of a revi'it and forbid consumption of more than a revi'it, or the like, Scripture related the problems that stem from it, for a great purpose; that a person should be wary of it; each person based on his own self-evaluation.
All translations of the Moreh Nevukhim are from the Pines edition.