Residential schools

Why were residential schools created and what was their purpose?