The principle to limit and prohibit on Shabbat are based on two biblical commandments: 1) the 39 melakhot, that create new things. 2) the general commandment to sanctify the day and refrain from ordinary mundane activities even if they are not actually included in the 39 melakhot.
While the Written Torah presents general principles, the Oral Torah expands on the details. The Sages were empowered to establish safeguards and ordinances to reinforce the Torah’s commandments and enable the fullest expression of their spirit (16:12 above). The rabbinic rules pertaining to Shabbat serve one of two purposes, which parallel the two reasons above: they are meant either to ensure that people not come to do a melakha, or to preserve the spirit of Shabbat as a day of sanctity and rest. In cases of great need, the Sages permitted transgressing the rules they established.