He was going to refuse. He didn't want to give Thanos the tesseract, he wanted to use it for himself. But when Thanos threw out a body, bounded by chains, Loki's demeanor changed. Seeing you bound as a prisoner, he wanted to save the day.
Most importantly, save you.