Why Set Theory as Foundation? Set Theory, particularly ZFC, is the most widely accepted foundation for mathematics.
Why is that? Why is Set Theory (and, in particular, ZFC) the (in some sense) "best" foundation we can come up with?
There doesn't seem to be any definite detailed answer to this question on the web or on this site.
 A: There are other foundational proposals, but set theory has two general advantages:
It works. Virtually all of everyday mathematics can be formalized in set theory, so we're pretty sure it contains the foundational uncertainty we will ever need to deal with.
It is reasonably close to how everyday mathematics is already done. Speaking of sets is ubiquitous in algebra, analysis, topology -- not because it has been decided that sets are foundational, but because sets naturally arise when expressing the things we're interested in there. For example, in group theory we want to talk about subgroups, and defining what a subgroup is naturally leads to an underlying concept of subset.
There are other kinds of things that arise naturally in ordinary mathematics -- numbers, tuples, relations, sequences, functions, etc. -- but most of these can be represented with sets in ways that feel relatively straightforwards. Numbers are probably the "least setlike" of the usual kinds of things used in ordinary mathematics, and the usual representations of numbers as sets is not particularly intuitive. But in the big picture that's not really a showstopper, and similar contortions would be needed elsewhere when one uses other foundations.
"Reasonably close to ordinary mathematics" has particular significance not so much for those working directly with foundational problems, as because because those working in ordinary mathematics can then feel reasonably comfortable with imagining they're working on top of set theory as a foundation. Since people working outside foundations are also most of those who teach the formalism in a typical undergraduate curriculum (because most professors of mathematics work outside foundations), this gives set theory a definite advantage in the battle for mindshare.
Among set theories, ZFC has the main benefit of being simple to explain. There is only one kind of thing: The set. The basic operations are conceptually simple. In particular the restrictions you work under to avoid the paradoxes are fairly easy to adhere to -- most of the way you can get by with Separation, which is much easier for non-specialists to understand and remember than, say, the "stratified" comprehension axiom of NF.
Among other foundations, the established proposals that come closer to set theory in matching how ordinary mathematics is done would be various kinds of category theory. To me -- and apparently to many others -- they feel somewhat more remote from how you think about ordinary mathematical reasoning than a set-theoretic foundation does. Especially because category theory considers talking about individual "things" to be something to be avoided, it seems to be harder to make a connection between the theoretical framework and actual calculations on concrete examples. But whether this feeling is inherent in the approach or just an effect of having more experience with set theory is very much a matter of debate.
Some up-and-coming ideas are modern type theories, generally building on a category-theoretic substratum, but with a computational slant that doesn't discourage thinking about individual elements the way classical category theory does. They might end up providing the best of multiple worlds once the technical kinks get evened out. Apart from the considerable inertia of ZFC, their main problem is that they don't have much parsimony of primitive notions. They don't work very well as neat packages of "all the foundational uncertainty we need to worry about".
Some also-rans: Foundations based on integer arithmetic as their primitive concept, such as various systems for second-order arithmetic, can express large parts of ordinary mathematics. But even though they can represent, say, reasoning about differential equations, the contortions that one needs to go through are complex and not intuitive at all. And these systems still cannot represent everything one wants to be able to do in ordinary mathematics. They are mostly studied for specialist purposes, e.g. in reverse mathematics because it is easier to construct interestingly restricted versions of second-order arithmetic than it is for set or category theory.
A: This is more of an HSM question, but I'll try to answer partly historically and partly in terms of theory.
Nineteenth-century paradoxes led to set theories such as ZFC. One advantage it has over some other theories is a lack of urelements, so we don't need a set predicate constantly cluttering axioms and theorems. The downside of that is you can't talk about anything that cannot be construed as a set. But it was quickly realised you can easily represent just about any "traditional" mathematical structure of interest through its isomorphism to a certain set's contents, provided we define operations on them the right way (e.g. if you think of finite ordinals as representing non-zero negative integers, it's not too hard to decide how we'll define arithmetic on them).
Around this time, the people interested in foundational questions were generally involved in set theory, to a greater or less extent or a more or less tangential one. For example, Russell's paradox comes from the more philosophically inclined of the authors of Principia Mathematica. Mathematicians had just had a few decades of a castle-building whirlwind, where complex numbers had lost their controversy and even more esoteric structures had entered the field. Were quaternions OK? What about groups? The realisation was that we should really ask what things do, not what they are, if only because there will be many structures that do the same thing.
So in short, what happened was this: people worried about which objects were legal noticed sets had been used uncritically, including in some cases sets of sets; set theory had to be given a bit of rigour just to avoid easily formulated paradoxes; but the seemingly robust ZFC, despite lacking urelements, could model everything before it, so anyone who believed ZFC was consistent was also assured "normal" maths is as well.
