The first two propositions of the Tractatus—"The world is all that is the case" and "The world is the totality of facts, not of things"—define what Wittgenstein means by "the world." A complete description of the world is not given by a complete catalogue of all the things in it, but by a complete catalogue of all the facts that hold of it.
The most basic kinds of facts are "states of affairs." These states of affairs are so simple that their truth or falsity has no bearing on the truth or falsity of any other state of affairs (1.21). When we think of more complex facts—for instance, that I have the only set of keys to the house in my pocket—we realize that their truth or falsity affects the truth or falsity of other possible facts—for instance, whether my sister will be able to get into the house, whether my pocket is full, whether my house is safe from burglary, etc. These more complex facts are composed of a number of basic states of affairs, which in turn are mutually independent. The sum total of true states of affairs (all that is the case) is the world.
Facts exist in what Wittgenstein calls "logical space" (1.13). Logical space is effectively the realm of everything that is logically possible. For instance, though it is not true that Toronto is the capital of Canada, there is nothing illogical about supposing that it might be, so its possibility exists in logical space. Some items in logical space (for instance, "Ottawa is the capital of Canada") are true, while some items in logical space are false. True or false, everything in logical space is possible. "Love is purple" is not an item in logical space, because it is not logically possible (love is not the kind of thing to which we can ascribe a color).
A state of affairs is a combination of objects (2.01). Every object has a logical form (2.0141) that determines how and in what kinds of states of affairs it can occur. Wittgenstein would not consider "love" to be an object, but it may help us to take it as an example. "Love is purple" is nonsensical because we cannot ascribe a color predicate to "love." The logical form of "love" dictates that it can occur in certain ways in certain sentences ("love is the opposite of hate") but not in others ("love is purple").
The logical form of an object does not determine which states of affairs it occurs in, but it does determine which states of affairs it can occur in. We do not know an object unless we know its possible occurrences in states of affairs (2.0123). To return to the earlier example, we don't know what the number two is if we say it is purple.
There is a branch of metaphysics called ontology that is dedicated to figuring out what sorts of things there are. The opening propositions of the Tractatus are devoted to ontological questions. Wittgenstein is categorizing what sorts of things exist, and what relationship they hold to one another.
Wittgenstein's ontology consists of objects and states of affairs, both of which exist in logical space. Let us first consider what he says about objects in 2.01–20141. Wittgenstein never gives us an example of what he means by "object," causing a great deal of debate among interpreters.
He introduces objects at 2.01 as the constituents of states of affairs, and elaborates at 2.011 that the possibility of constituting states of affairs is the essence of an object. Philosophers talk about the "essence" of a thing as the properties which make the thing what it is, without which it would be something different. Aristotle defined humans as rational animals: we can lose a leg and still be human, but we can't be human if we aren't rational. Wittgenstein is suggesting that the essence of any object is not certain properties that hold of it, but the possibility of certain kinds of properties holding of it.
Wittgenstein illustrates this point at 2.0131: "A speck in the visual field, though it need not be red, must have some color: it is, so to speak, surrounded by color-space. Notes must have some pitch, objects of the sense of touch some degree of hardness, and so on." An object need not exist in any particular state of affairs, but it must exist in some state of affairs. In the same way that notes must have some pitch, and that pitch exists in what we might call "sound-space," objects must exist in some states of affairs, and those states of affairs exist in logical space.
We might visualize logical space as a grid of light bulbs. Each light bulb represents a possible state of affairs. Behind this grid we can imagine objects as independent power sources, each with wires (different kinds of wires for different kinds of objects) coming out of them, connecting with all light bulbs that have sockets for that particular kind of wire. Any given light bulb will have a number of different wires plugging into it, just as any state of affairs is a combination of a number of different objects. Depending on how these different wires plug into the bulb, they will either conflict, and prevent any power coming to the bulb, or they will combine to turn the light bulb on. Lit light bulbs represent states of affairs that are the case, and unlit light bulbs represent states of affairs that are not the case. The world is the totality of lit light bulbs, whereas unlit light bulbs represent possibilities that are not the case.
This metaphor helps explain a number of key points. First, states of affairs are mutually independent: any given light bulb can be lit or unlit without affecting any of the other light bulbs. Second, the essence of an object is its possibility of existing in certain states of affairs: the significance of the power source lies in which light bulbs it plugs into, and how it does so. Third, the world is "the totality of facts, not of things" (1.1): the world is the totality of lit light bulbs, not of power sources.
Wittgenstein's ontology of states of affairs in logical space effectively limits what there is to what is the case. We cannot say that certain things exist or don't exist: we can only state facts about the world that relate these things to other things and properties. The only way to deal with the question of whether or not unicorns exist is to list all the facts that are the case about unicorns. When we find that there has never been a reliable sighting of a unicorn, and that they have only been encountered in imaginative fiction, we might draw certain conclusions about whether there are any flesh and blood unicorns. To exclude unicorns from our ontology altogether does not even make sense, since it is an ontology made up of facts, and not things. Unicorns can be said not to exist only to the extent that there are no true facts that assert something about unicorns as flesh and blood creatures.