A UK-based spy ring passed secrets to Russia for nearly three years, endangering the national interest and putting “many lives at risk”, a court has heard.