A former soldier accused of spying for Iran launched a "hare-brained" scheme to become a double agent but "without betraying or hurting anyone", according to his defence.