"Did you then think that We had created you in vain," meaning: without resurrection or reckoning, "and that you would not be returned to Us?" This is posed in the interrogative form, meaning: You had thought that, but We did not create you in vain; We only created you for resurrection and reckoning.
﴿أفحسبتم أَنما خَلَقْنَاكُمْ عَبَثا﴾ أَيْ: لِغَيْرِ بَعْثٍ وَلَا حِسَابٍ ﴿وأنكم إِلَيْنَا لَا ترجعون﴾ وَهُوَ عَلَى الِاسْتِفْهَامِ؛ أَيْ: قَدْ حَسِبْتُمْ ذَلِكَ؛ وَلَمْ نَخْلُقْكُمْ عَبَثًا، إِنَّمَا خَلَقْنَاكُمْ للبعث والحساب