Section 17. The state treasurer may receive the principal of any fund given or bequeathed to the commonwealth or the department of mental health for the use of mentally ill persons or to the commonwealth or the department of developmental services for the use of persons with an intellectual disability; and upon the request of the department of mental health in the case of funds for the use of mentally ill persons, or upon the request of the department of developmental services in the case of funds for the use of persons with an intellectual disability, the state treasurer shall expend the income of all such funds, and such part of the principal as may be subject to the control of the respective department, in such manner as it may direct, subject to any condition affecting the administration thereof. Said funds shall be invested safely by the state treasurer, and he shall be held responsible for the faithful management of the same in the same manner as for other funds held by him.