How does the judiciary balance individual rights with the concept of 'larger public interest' in sensitive criminal cases?

The Uttarakhand High Court stayed a scientist’s conviction citing 'larger public interest.' I want to understand how courts interpret and apply this principle, especially when individual justice and societal welfare may conflict.