Yes life has a purpose
From the perspective of humankind, the question “Why did God create man?” implies “For what purpose was man created?”
“I have created the jinn and humankind only for My worship.”
“None of those who call me ‘Lord’ will enter the kingdom of God, but only the one who does the will of my Father in heaven.”
“Whoever therefore breaks one of the least of these commandments, and teaches men so, shall be called least in the kingdom of heaven; but whoever does and teaches them, he shall be called great in the kingdom of heaven.”
“[Remember] when your Lord extracted from the loins of Adam’s children their descendants and made them testify [saying]: ‘Am I not your Lord?’ They said: ‘Yes, we testify to it.’ [This was] in case you say on the Day of Judgment: ‘We were unaware of this.’ Or you say: ‘It was our ancestors who worshipped others besides God and we are only their descendants. Will you then destroy us for what those liars did?’” (Quran 7:172)
The purpose of life is to worship god.