Teil is an example for one of the German nouns that has two genders, and where each gender actually comes with a different meaning.
Das Teil is the part in the sense of physical part of something. Like, think of a machine that has many parts.
Der Teil is the part in the more figurative sense of part of a whole. That can be a part of a movie, a part of a team or a part of your salary. It can also be a tangible part, like a part of the beers in the fridge.
By the way, the noun Teil and the verb teilen are actually related to the English deal, but deal has shifted from the sense of dividing to the idea of giving a part to someone.
If you want to read more about this, check out this article on YourDailyGerman: