In the sentence: "Drinking and driving is dangerous". Drinking and driving are both subjects and the word dangerous is the object (I think) but why do I have to use the verb to be in singular?
Because drinking isn't dangerous, and driving isn't dangerous – at least, not in comparison to the single activity "drinking and driving" – the two words are treated as a single unit.
This might happen a lot when we combine two or more elements in a sentence:
My favorite drinks are gin and tonic.
This could mean I have two favorite drinks: gin is a favorite drink, and so is tonic.
My favorite drink is gin and tonic.
This means that a gin-and-tonic is my favorite drink.
If you say:
Drinking and driving are dangerous.
this is the equivalent of saying:
Drinking is dangerous. Driving is dangerous.
Drinking and driving is dangerous.
we mean that drinking to the state of being intoxicated, even mildly, and then driving while still intoxicated, is dangerous. However, the quote is much pithier than the explanation!
The combination of drinking and driving is a single object. Here we see one combination of two things. The common phrase 'drinking and driving is dangerous' is leaving out some clarifying words.
"Drinking and driving are dangerous" has a particular meaning: drinking is dangerous (perhaps) and driving is dangerous (perhaps), if you look at each singularly. The meaning of your sentence is that [the combination of] drinking and driving is dangerous.
An new example of 'is vs. are' with clearer context may help: Singing and rock climbing are challenging activities. Singing while rock climbing is a more challenging activity.
In standard English when a list of items is used as the subject of a verb then, that verb takes the plural even if all the items in the list are singular.
For example you would say
Gold, iron, copper and aluminium are metals rather than is metals (although some dialect have the opposite convention).
BUT 'drinking and driving' is a list but effectively a single compound noun. actually 'drunk driving' would be more grammatically correct but has been abandoned as the precise definition of 'drunk' is too ambiguous in this context and the phrase is used to reinforce the idea that drinking any alcohol before driving is dangerous even if you don't think you are 'drunk'.
This is different to saying 'drinking is dangerous, driving is dangerous'.
It is the singular act of drinking and driving that is being described as dangerous. In describing multiple acts that are individually considered to be dangerous you would use the plural form of the verb.
- Drinking and driving is dangerous and illegal.
- Smoking and mountain climbing are dangerous and legal.
This won't be a popular opinion, but this is precisely why I have always considered this sentence to be "wrong, but common enough to not be worth correcting", with the correct way to write them being via hyphens:
Drinking-and-driving is dangerous.
But fellow netizens will beat you up the moment you dare suggest this, because they point out that there is no Official English Grammar, and hence anything the general population feels like calling "correct English" on their Thursday of choice is, by definition, Correct English.