So in a vacuum, that is, valuing weakness/resistance against each type as equal (i.e. resistance against Rock is valued as useful as resistance against Normal for example, which may not be the case in practice with things like Stealth Rock),
Steel/Fairy is probably the best defensive typing, as it has the highest number of resistances/immunities minus number of weaknesses with 9 (11 minus 2). It's tied with
Normal/Steel and
Steel/Electric, but unlike the two, Steel/Fairy has no double weakness.
Offensively it'd be
Ground/Ice, which hits super effective against 109/171 typings and is only resisted by 2 typings (x0.5 against Bug/Water and Bug/Ice). The only typing resisted by 1 typing is
Fighting/Ghost, but it's a x0 against Normal/Ghost.
You can check the full statistics
here.
Now, evaluating at both defensive and offensive aspects is rather tricky. My idea is to have each of the 171 typings face off one another. During each matches, say between typing A/B against typing C/D (A the same as B and C the same as D, to account monotypes), I calculate which of A and B has the better effectiveness (x4, x2, x1, x0.5, x0.25, or x0) against typing C/D, let's call this effectiveness as max(A/B). Likewise I calculate max(C/D), then compare max(A/B) with max(C/D). If max(A/B)>max(C/D) then typing A/B wins the match, and if vice versa then typing C/D wins the match, otherwise it's a draw.
With number of wins minus number of losses as the basis for the ranking, the best typings are
Flying/Steel (96 minus 35, also the highest number of wins),
Flying/Ground, and
Ground/Fire (both 91 minus 30). The lowest number of losses is
Water/Dragon with 17.
The full table can be checked
here.
All of the above are somewhat impractical, but I still find them interesting to share.