The correct sentence with appropriate usage of verbs is:
They had roamed the earth for more than a hundred million years before they became extinct.
The above sentence is correct because the sentence makes the appropriate usage of past perfect tense, past perfect tense refers to the actions which have begun in the past and finished in the past itself when another action happened.
It is formed by, had + past form of the verb
In the above sentence, the first action that “they roamed the earth” is finished by the second act of becoming extinct. Hence it uses two actions in the past therefore, it used the correct form of the verb tense.