The old man wondered why his life had slipped away in vain.
Literal
Old-man [topic-は] life [subject-が] in-vain passed-away [nominalizer-の] [topic-は] why was [question-のか] [quotative-と] pondered.
いたずらに ('in vain, idly') is a literary adverb. ~てしまった marks the passing as complete and regrettable. The whole のは~のか clause embeds a reflective question inside と考えた ('pondered'). A contemplative sentence about mortality and wasted years.