I think he did what the higher ups wanted to keep his job.
The higher ups like the Kennedys or LBJ’s with their historical squads of sympathizers have tried to rewrite history to make J. Edgar Hoover more sinister and an instigator of bad stuff who blackmailed the presidents.
The Left took a beating from the FBI spying operation and their revenge ironically was to brand him as a gay man.
The same Left that will claim to be on the side of gay people nowadays.
J Edgar was probably in office way past his shelf date.
I think on the whole he did more good then harm. I lot of people forget that he was very opposed to the FDR executive order putting Japanese-Americans in camps. He viewed them as no threat. WW2 FBI CI was pretty effective as was FBI CI during his tenure in the Cold War. Knocks against him in WW2 was primarily over his failure to understand the difference between law enforcement and intelligence gathering. As well as bureaucratic fighting with OSS & the military intelligence services but somehow after much gnashing of teeth it all worked. Whether he was gay or not is still open to question. There is no unimpeachable sources for it. All who claim have only their word and an axe to grind. The strongest evidence is that he never married and co-owned a DC townhouse with his FBI No 2. At the time the view would have been two dedicated public servants married to their jobs. I think he was nonsexual or asexual. These people do exist!