The Scottish government has introduced emergency legislation in response to the cost of living crisis, aimed at freezing most rents until the end of March 2023.