The answer depends foremost on what exactly you mean by "a sound", which could be counted. For example, the consonant [ʕ] is found in Arabic, Tigre, Somali, Chechen and a number of other languages. However, the exact pronunciation differs, so that [ʕ] in Moroccan Arabic isn't phonetically the same as it is in Levantine Arabic. Aspirated stops differ quite considerably in how much aspiration there is (e.g. in Navaho they are very aspirated but in (related) Apache, not so much. If you are looking for fine-grained phonetic differences, the answer would be along the lines of "unlimited" (or at least unknowably huge).
On the other hand, if you are looking at phonemes, the answer is more computable. Although English phonetically has alveolar t (the regular case) and dental [t̪] (in "width"), this is an automatic feature of English pronunciation (or possibly universally required). However, [t] versus [t̪] is a phonemic choice in some languages (Ekoti). The IPA is a conventional system for writing all such phonemic distinctions in languages. You can start calculating from a chart like this (I warn you however that that is an unofficial homebrew version, and one should always consult the official version. In fact, the Wiki page for IPA is on the verge of being offensively misrepresentative). So for plain voiceless stops, you have [p t̪ t ʈ c k q]. Any of these can have rounding as a secondary articulation (notated in IPA as ʷ), and many can have palatalization (ʲ). Additionally, you can have differences between plain, aspirated, and ejective stops (p, pʰ, p') – so you have 7x2x3 i.e. 42 kind of voiceless stops (there are other properties that have to be considered, and a question of whether there is such a difference as [kʲ] versus [c], or [qʲ] at all). You can basically triple that number to include voiced and nasal consonants, and then there are fricatives and so on.
IPA has 28 vowel symbols (this is a proper vowel chart). Any one of these can be modified by diacritically-indicated additional properties, such as nasalization, or creakiness vs. breathiness (the former can theoretically combine with either of the latter but the last two are mutually exclusive), which gives 28x2x3 vowels; then we can add length (2 or maybe 3 categories) and tone (errrm, that's a big number).
One problem you run into is the attestation gap. For example as far as I know, no language has [ʏ̤] (breathy lax [y]), which probably means we just haven't found it, since breathiness is not a very common phonetic feature. A related problem is that some of the odd sounds have an unclear phonetic and phonemic status. Clicks are a good example: some of the Khoisan languages like Taa have a huge number of click distinctions, so [kʘ kʘʰ* ɡʘ ɡʘh ɡʘqʼ kʘʼqʼ ɡʘx ...]. Some of these clearly fall within the purview of normal voicing / aspiration / nasalization distinctions, but there seem to be inconveniently more kinds. The "velar fricative release" click [ɡʘx] might be a consonant cluster of [ɡʘ] plus [x], and there isn't any clear way to determine if that is correct / wrong.
This at any rate gives one an initial basis for computing "possibilities". The biggest impediment to giving a concrete number is that there are many rare phonetic properties attested especially in languages with few speakers (under 100,000), but not a lot of clear, probative data as to what distinctive properties there are. As for the question of a theory of such oppositions, starting with Roman Jakobson at the end of the 1940's and at least until 1995-ish, sounds have been analysed into a system of independent features, where (in one standard system - the last standard), [p] is [+consonantal, -sonorant, -syllabic, -voice, -continuant, +anterior, -coronal...]. That system (Sound Pattern of English) has about 24 features (it does not actually say explicity which things are or are not features, and it proposes distinctions that nobody adopted). That gives a mathematical upper limit (around 16 million) which is certainly vastly more than anyone has actually observed. The underlying theory is that these specific properties are part of our biological faculty of language.
An alternative approach is that the biological faculty of language has simply the notion "feature", and a general relationship between "feature" and aspect of language (i.e. rule or phonemic distinction – rules operate in terms of feature values, sounds are distinguished in terms of features), but there is no actual substance of the features (i.e. nothing in the theory of grammar requires you to know that the sounds participating in a rule are produced by lowering the velum, or protruding the lips).