Let's look at the story from the Mahābhārata. Bhīṣma narrates this to Satyavatī after he has just told her he cannot break his vow of brahmacarya (by performing niyoga on her daughters-in-law):
Ādi Parva; Saṃbhava Parva; Ch. 97-98
O queen! In order to prevent Shantanu's lineage from becoming extinct, I will tell you the eternal dharma of Kshatriyas. Hearing this, after consulting priests and those wise ones who know about the dharma that should be followed in time of calamities, determine what is best for the welfare of the world.
Jamadagni's son Rama was angry when his father was killed and in his anger, the immensely illustrious one killed the king of the Haihayas. He sliced off Arjuna's 1000 arms. Then he again took up his bow to conquer the world. Using his wonderful weapons, the great-souled descendant of Bhargava used his arrows to exterminate Kshatriyas from the world twenty-one times. Then Kshatriya women everywhere had offspring through Brahmanas who were self-controlled. The Vedas clearly say that a son so born belongs to the one who accepted the hand. With dharma in their minds, they united with the Brahmanas. The world has thus seen the resurgence of the Kshatriyas.
In earlier times, there was a famous and wise rishi named Utathya. His wife was named Mamata and he loved her dearly. Utathya's younger brother was the immensely energetic Brihaspati, the priest of the gods. He desired Mamata and sought to unite with her. Mamata told her brother-in-law, who was most eloquent in speech, 'I am pregnant through your older brother. Therefore, desist. O illustrious Brihaspati! Utathya's son is in my womb and has studied the Vedas and the Vedangas there. Your semen is infallible and, therefore, this is not possible. Do not desire me today.' At these words, the immensely energetic Brihaspati could not suppress his desire, though he had achieved self-control. The desiring one united with her, though she did not desire him in return. When he spilt his semen, the embryo inside the womb said, 'O father! There is no room inside for two of us. I was here first and you have unnecessarily wasted your semen.' At this, the illustrious rishi Brihaspati was angry and cursed Utathya's son, who was in the womb. 'You have spoken at a time that all beings crave for. Therefore, you will enter a long period of darkness.' From this curse was born the rishi Dirghatama. He was Brihaspati's equal in great deeds and great energy. To extend Utathya's lineage, the famous rishi had sons like Goutama and others, all immensely famous.
But Goutama and the other sons were overcome by greed and delusion. They tied him to wood and threw him into the waters of the Ganga. 'This man is blind and old. Why should we support him?' Thinking in this way, the cruel ones returned home...
(Debroy, Bibek. The Mahabharata: Volume 1, pp. 274-276)
Note that Mamatā only says, I am pregnant through your older brother. Therefore, desist...Do not desire me today; she doesn't quote from dharma śāstras e.g., Manusmṛti 9.57-58 which prohibit either brother from approaching the other's wife during normal times. This means rules like these based on which we are now judging Bṛhaspati came much later.
The wife of the elder brother is, for the younger, a 'wife of the preceptor'; and the wife of the younger brother has been declared to be a 'daughter-in-law' for the elder.—(9.57)
If the elder brother has recourse to the wife of the younger, or the younger brother to the wife of the elder, they become outcasts, even though 'authorised,'—except in times of distress.—(9.58)
On failure of issue, the woman, on being authorised, may obtain, in the proper manner, the desired offspring, either from her younger brother-in-law or from a ‘Sapiṇḍa’.—(9.59)
Iravati Karve attempts to solve this apparent contradiction in Kinship Terms and the Family Organization as Found in the Critical Edition of the Mahābhārata where she says, there must have been a time when the younger brother could access the elder brother's wife to fulfill his sexual needs even when the elder brother is still alive:
The customs of Niyoga and levirate, implying a certain approach to
polyandrous unions are found in the epic. The story of Bṛhaspati and
Mamatā shows that a younger brother had access to the elder brother's
wife. The evidence is, however, rather confusing, Dharmarāja’s speech
to Arjuna where the junior levirate is implied, is as follows.
guror anupraveśo hi nopaghāto yavīyasaḥ ... etc. 1.205.27
The word anupraveśa here means not just following but the exercise of marital rights after somebody else. The same word is used when Satyavatī tells her daughter-in-law, "Kausalyā: you have a husband's brother. He will come to you today."
kausalye devaras te 'sti so 'dya tvānupravekṣyati 1.100.2.
Also the objection raised by Draupadī's brother Dhṛṣṭadyumna
indirectly lends support to junior levirate (1.188.10). "How can the
elder brother, knowing dharma, go with the wife of a younger?"
yavīyasaḥ kathaṃ bhāryāṃ jyeṣṭho bhrātā dvijarṣabha |
brahman samabhivarteta sadvṛttaḥ saṃs tapodhana ||
Accordingly Kṛṣṇā (Draupadī) was married to the five brothers one after
another, the eldest coming first and the others following according to
seniority. But actually when Satyavatī bids Bhīṣma to impregnate his
younger brother’s wives this is against the sentiment expressed above.
(1.97.8, 9, 10). Also when Kṛṣṇa in order to get Karṇa on the side of
Pāṇḍavas tells him, that, not only will he be the king as the eldest
of brothers but he will also in due time have Draupadī as his wife in
common with the other brothers. (5.138.15.)
ṣaṣṭhe ca tvāṃ tathā kāle draupady upagamiṣyati
We may infer that junior levitate was preferred but in certain
circumstances even senior levirate was practised. The marriage of
Draupadī must be looked upon also as a special modification of this
custom of levirate. A man had a right to his elder brother’s wife even
during the lifetime of his brother as the story of Bṛhaspati and
Mamatā shows; this right however was exercised without the
brother-in-law being the husband of his brother’s wife. Nor could the
children be claimed as his; however, by undergoing the formal
marriage ritual all the brothers could have own sons from the woman.
So, to answer your question – Why did the Devas let Bṛhaspati be their guru even though he had sex with his brothers' wives? – it's because it was legal at one point.