Why do squids have ink?

It's for their own protection - a way of repelling predators it blocks enemy sight so the squids can run