Holyrood is taking on a range of welfare powers under the Scotland Act 2016, and is setting up a dedicated body to oversee them.
The Social Security (Scotland) Bill will give the Scottish government the power to deliver 11 benefits.
These include disability living allowance, personal independence payments, carer's allowances and winter fuel payments.
Social Security Secretary Angela Constance has announced the timetable for delivery of the first benefits to be devolved.
Under the plans, an increased carer's allowance would be payable from the summer of 2018, while the Best Start Grant, a replacement for the maternity grant to target child poverty, and the Funeral Expense Assistance grant would be paid from the summer of 2019.
The bill now tabled at Holyrood provides a mechanism to pay a carer's allowance supplement at the earliest opportunity, as well as powers to top up reserved benefits.
It provides the over-arching framework for the administration of social security in Scotland, and places a duty on Scottish ministers to give assistance to persons entitled to it.
Social Security Minister Jeane Freeman said the legislation was a "significant moment for Scotland and for the history of devolution".
She said: "I believe strongly that everyone has a right to social security - so much so that I have put these principles on the very first page of this Bill.
"And these principles are embedded in our approach throughout - whether it is how entitlement to benefits is determined, a more just review and appeals system, or our decision to remove the private sector from disability benefit assessments."
Legislation to set up a Scottish social security agency has been published.