Is it possible that the Torah could be considered Lashon HaRah? It describes personal information about both individuals and groups of people and documents their good, bad, and indifferent behaviours. This has lead to both praise and criticism of even the Prophets.
No the authorship of the whole Tanakh doesn't constitute l'shon hara since the purpose was positive; to teach lessons to future generations (Megillah 14a). Information, even negative information, that is inteded for some positive purpose, and not just to defame someone, is by deifinition not l'shon hara.
This is the opinion of numerous authorities including R. Menahem HaMeiri who writes that the definition of l'shon hara, is speech that is meant to be defamatory or hurtful. Thus, statements of a negative nature that are said for a positive reason and not to hurt others, are permissible since by definition they are not l'shon hara. These are his words in is Hibbur HaTeshuva (Meshiv Nefesh I:4):
עקר לשון הרע הוא המתמיד לספר בגנות האחרים ויתן דפי בענינים או שילעג להם למעוט הצלחתם...ומעין זה מי שילעיג על חבריו למעוט השגתם בידיעה...לכונת לעג וליצנות...וכלל הדברים כל אשר יתן מום באדם...ללא כונת ענין נבחר הוא ענין לשון הרע...שאין לספר במומי בני האדם על דרך לעג וליצנות, אם לא יעשה כן...לאיזו כונה
The archetypal l'shon hara is one who frequently relates embarrassing things about others, and adds falsehood to what he says, or he defames them on their lack of success...And similarly one who defames his fellows on their lack of intellect for the purpose of defamation and mockery...The rule is that anyone who ascribes a fault to others...without some specific intent is l'shon hara...For one should not relate the faults of others in context of defamation and mockery, unless he is speaking for some purpose. (Translation my own).
This also appears to be the opinion of R. Elhanan Wasserman, who generalises this to all interpersonal mitsvot. He writes in Kovets Ha’arot (Yevamot: 70):
ולולי דבריהם היה נראה, דכל האיסורין שבין אדם לחבירו אינן איסורין אלא דרך קילקול והשחתה שלא לצורך... וכן בלאו דלא תלך רכיל, מותר לספר לה"ר על בעלי מחלוקת כדי להשקיט המריבה. וכן בלאו דאונאת דברים... ומוכח מכ"ז, דכל האיסורין האלו הותרו לצורך תועלת
If not for their words, it would appear that all interpersonal prohibitions, are only forbidden in the context of degrading and tarnishing others for no purpose...And so too with the prohibition of gossiping, it is permitted to tell l'shon hara on disputants to quell the dispute...And similarly with the prohibition of onaat d'varim [verbal abuse]...And it is evident from all this that all of these prohibition are permitted to achieve an end. (Trans. my own).
Importantly, they do not attach conditions to to'elet, as the Haffets Hayyim famously does.
Similarly, the eminent modern day halakhic authority, R. Asher Weiss Shlit"a writes in Minhat Asher to Leviticus (p. 268) that to'elet renders speech permissible and not l'shon hara, by definition.
באיסורי תורה צריך לדון בדיני דחיה האם תועלת זו ראויה לדחות איסור ...אבל בהלכות לשה"ר לאו מדין דחיה אתינן עלה, אלא יסוד האיסור תלוי במדה רעה וכל שכונתו לטובה...ולא לרעתו אין בזה עבירה כלל, ודו"ק בכ"ז כי לענ"ד ברור הוא
With Torah prohibitions one must evaluate with the laws of dehiya [prioritisation], whether this to'elet [purpose] is sufficient to supersede a prohibition. But with the laws of l'shon hara, we are not utilising the law of supercession. Rather, the very definition of the prohibition depends on negative character traits, and anything in which his intent is for good...and not for someone else's harm, has no prohibition whatsoever, and consider all of this, for in my humble opinion, it is clear.
He shows that this is the opinion of Rashi (Moed Katan 16a s.v. amar lei la'avuha) and sharply disputes (p. 267) the Haffets Hayyim's attempt at escaping the implication of Rashi:
אך בחפץ חיים...כתב...ודבריו קשים לכאו' דמלבד שאין הדברים מתיישבים בלשון רש"י
However in Haffets Hayyim...he wrote...and his words appear difficult, for besides for the fact that his words don't fit with Rashi's wording...
[Like R. Elhanan, he connects this to the idea that interpersonal mitsvot in general are by definition only prohibited when they are malicious. (In particular he connects this to the prohibition of overcharging, see p. 267)].
This apparently nearly unanimous view expressed by the Meiri, R. Wasserman, R. Weiss, and the numerous authorities they cite as support, is expressed by R. David Cohen Shlit"a, as well:
This to my mind [is similar to when] the poskim speak about lashon harah l’toeles [for a helpful purpose], which is not limited to loshan harah. Any [transgression of] bein adam l’chaveiro [when it is] l’toeles is mutar (cited here, page 7)
Importantly R. Weiss clarifies (p. 267) that there are limits to the limitation of l'shon hara to cases of malicious intent:
דשאני המספר לשה"ר דרך קלות ראש דהרי פושע גמור ובזה ודאי עובר בחטא כיון שהדברים מצד עצמם הם לשה"ר גמור ובדרך שחוק וקלות ראש מנבל הוא את פיו בכה"ג פושע הוא אף שלא התכוין להרע לחבירו
For it is different if a person speaks l'shon hara with frivolity, since the matters are intrinsically l'shon hara and in the context of frivolity and levity, he pollutes his mouth. In such a case, he is a willful sinner even though he didn't intent to harm his fellow.
That is: "I was just having a good time", isn't a legitimate excuse to speak disparagingly about someone. However, by all indications, relating incidents about others for the purpose of conveying vital lessons to future generations would be permitted.
None of this takes into account an additional reason that Tanakh may be appropriate; that its authorship and compilation may have been guided by ruah hakodesh.
If the question is about the Torah in particular, that was generally understood to have simply been recorded by Moshe on God's orders, so he wouldn't have violated l'shon hara.
Mostly no. One is permitted to speak badly about others when
A) the speech concerns a Rasha doing a sin (korach) B) A publicly known matter (Solomon having too many wives and doing idolatry)
What about when David sinned with Batsheva, which didn't affect the public and he wasn't genuinely a rasha?
I would have to say that it became a public matter when God sent a prophet to rebuke him in the court.
As for Moses' not circumcising his son, I don't have an answer other than humble Moses said insisted it be recorded.