Why is that a lot of languages have the distinction between voiceless-voiced consonant but not a lot of languages have three-way distinction between voiced, voiceless unaspirated, and aspirated consonants?
Phonetically, "aspirated", "tenuis" (i.e. not aspirated or voiced), and "voiced" stops are primarily distinguished by voice onset time, the time between the release of the stop and the start of voicing. The more negative the VOT, the more voiced the stop; the more positive the VOT, the more aspirated.
It's quite common for languages to have a two-way distinction in VOT. For example, Spanish, English, and Mandarin all have this two-way distinction. But they all draw the dividing line in different places. In Spanish, the dividing line is farther to the voiced end of the spectrum, separating negative values from close-to-zero values. In English, it's more on the aspirated end, separating close-to-zero values from positive values. And in Mandarin, it's even farther toward the aspirated end, separating small positive values from large ones.
The decision, then, to call this a "voicing" or an "aspiration" distinction is somewhat arbitrary. English "voiced" stops often correspond to Spanish "tenuis" stops, having VOT values close to zero—but at the same time they're more voiced than their Mandarin equivalents. Does that mean English has an "aspiration" distinction or a "voicing" distinction? It really comes down to the phonologist doing the analysis. Some people prefer to call the more-aspirated series "fortis" and the less-aspirated series "lenis" as a more neutral way to discuss these issues; we can then say Spanish, English, and Mandarin all have a two-way fortis/lenis distinction in their stops.
What's rarer is a three-way distinction in VOT, as found in, say, Ancient Greek, or some varieties of Korean. Even here, though, the terminology can vary somewhat: Korean stops are usually described as "lenis", "fortis", and "aspirated", for example, rather than "voiced" and "voiceless" (since the VOT on the "voiced" stops tends not to be especially negative).
As Draconis says, the three phonations described in the question (aspirated, voiceless unaspirated aka tenuis, & voiced) are distinguished primarily by voice onset time (VOT), i.e. when does voicing start relative to the point of maximum restriction of the vocal tract, with voicing continuing through the point of maximum restriction in voiced consonants, voicing only starting after the consonant has been released in aspirated consonants, and voicing starting about the same time as the point of maximum restriction in tenuis consonants.
Three-way distinctions on any one feature are quite rare cross-linguistically.
There are apparent examples (e.g. Estonian has a three-way distinction on vowel length, and many languages in Africa have a three-way level tone system of high, medium, and low), but for the most part, languages tend to like features that are either present or absent, rather than ones having degrees . In fact, the Estonian example is usually analysed as a result of an underlying short or long vowel, and the presence or absence of suprasegmental lengthening (which can only apply to long vowels).
The few examples I know of modern languages with supposed three-way VOT distinctions are also far from clear-cut. Varieties of Armenian with three distinct series frequently glottalise their tenuis stops having them as ejectives, and Wu Chinese usually pronounce their voiced stops with breathy rather than modal voice. In both cases, this arguably introduces a second feature, and allowing both features to be binary. Speakers are not normally aware of the "hidden" feature, and perceive it as a linear three-way distinction, but this feature may still be present at an underlying phonemic level.
Other modern languages with three-way distinctions have much more overt second features. Arabic (and other Semitic languages)' emphatic consonants are pharyngealised (or glottalised) and contrast with the voiceless (usually aspirated), and voiced consonants; and Korean has its tense/fortis consonants contrasting with its plain and aspirated consonants.
I would suggest that the simplest explanation is that genuine three-way distinctions (in particular in VOT) are inherently unstable, with the human brain preferring binary features, and will always collapse, either using a "hidden" feature (as in Armenian or Wu), adding an additional feature explicitly (which could result in a four or three-way distinction), or reduction in the number of distinctions.
I don't have examples for those last two that are clearly to do with VOT specifically, but PIE had a three-way "voicing" system which in Proto-Indo-Iranian became four-way (but making aspiration and voicing entirely independent features and adding a new voiceless aspirate series), and outside of Greek, Armenian, and Indo-Iranian the system reduced to a two-way voicing distinction.
Ancient Greek is reconstructed with a three-way VOT distinction, but around the time of the formation of the Hellenistic Koine, this broke down, with the aspirated and voiced stops, and voicing the tenuis stops after nasals, reducing to a two-way voicing distinction.
The fact this occurred after a major disruption to the Greek-speaking world (rapid dominance by an Atticised Macedonian elite, and spread to many previously non-Greek-speaking areas) is not necessarily a coincidence. If Ancient Greek had a "hidden" feature like that in Armenian or Wu (note that this is highly speculative on my part, and there is no evidence to speak of for any specific such feature), such a disruption could easily lead to confusion over its presence or absence, producing a genuine three-way distinction which collapsed into the two-way distinction of Modern Greek.