This is the best car in the garage.
We use articles like the and a before nouns, like car. The word "best" is an adjective, and adjectives do not take articles by themselves. Because the noun car is modified by the superlative adjective best, and because this makes the noun car definite in this context, we use the.
It is best not to do something.
Here, we have the adjective best, but this adjective is attached to no noun.
The adjective best is used in a copular construction with the dummy pronoun it. This pronoun does not refer to any object. There's no noun that we can attach the to here.