It's known that every molecule is moving around at any time. But how can they form a solid object, like a cup, or a human? Also, I think according to statistics, all molecules should have been homogenerous mixed after such a long time since the Big Bang. Where do the solid objects in universe come from? I guess there may be many factors working here.....
So your thought about statistics would be correct if not for one basic fact about atoms and molecules:
Molecules are sticky.
There's actually a couple of different ways that molecules can be sticky, which is why when you put oil into water the oil sticks to itself and the water sticks to itself, but they don't stick to each other.
In fact when things are intrinsically sticky, they're more likely to be found near each other, as they spend some time stuck to each other. The exact probability depends on a bunch of numbers, but one very important number is called the temperature, which can be thought of as the average energy occupying all of the "degrees of freedom" that the system can move in. The second law of thermodynamics has a nice interpretation as just saying that as we get more uncertain about the system it's more likely that energy we're certain about in one degree of freedom gets knocked into these other degrees of freedom that we have much less information and certainty about, and so everything is trending towards having this "thermal equilibrium" where all of its degrees of freedom are occupied by the same average "thermal energy" with a characteristic random fluctuation of energy between those degrees of freedom.
For a high temperature the stickiness hardly matters. For a low temperature the stickiness overwhelms the thermal effects and everything ends up stuck together. Since temperature is a measure of average thermal energy, this means that we think about an "interaction energy" that two particles have to be together versus apart. As the above picture suggests, things stick together because the amount of energy they get from being together, being out in the rest of the world's degrees of freedom, leads to more total uncertainty than just those particles being apart. This is a very abstract idea and takes Bachelor's students a lot of thinking about to learn, so you might want to re-read that sentence a few times in a quiet corner or so. The uncertainty of the universe might be greater if two particles are stuck together, if this liberates enough energy that other things can be vibrating more.
One of the easiest ways to see this "spontaneous self-organization" is to create your own liquid crystal phase, if you happen to have a smallish box and a bunch of cotton swabs and you do not have to deal with very particular parents or roommates. First dump a bunch of cotton swabs onto a flat surface, then start haphazardly running your hands through them, tossing them about, "randomizing" their configuration. Once the chaos is complete, pick them up and fit a bunch into the box, trying to preserve as much chaos as possible. Once you pack them into the box you may find that shutting the box is hard and that the cotton swabs are very much stuck in place and there is not very much free space to place a new swab. You might think that this is the "most random" configuration you can create. But is this what the universe thinks?
Now, while holding the box closed, shake it randomly. You might hear nothing at first. Eventually, you'll hear some rattling, then more rattling, then more rattling. And if you shake it randomly for long enough you will see a startling result: all of the swabs have lined up, and there's a bunch of free space in the box. The swabs are forming what we call a "liquid crystal" phase where they are all structured and lined up but they are all moving freely as well. The universe cares about that freedom to move side-to-side, that is another form of uncertainty for the system: so as the system progresses to its most-uncertain state it will sacrifice some of the position-uncertainty to create this momentum-uncertainty.
There's a lot more here to unpack, since a lot of things like metals happen to have a crystal lattice that they fall into at low temperatures, and so forth. But crystallization is fundamentally the same process. Today we grow ultra-pure silicon crystals for all of our computers. How do we do this? We just try to make the system as quiet as possible, inject some silicon atoms near a "seed crystal" that we're trying to "grow", and let the stickiness of the molecules do its job. At low temperatures there is an exact location which is the "most sticky" that the silicon atom will fall into, growing the crystal lattice. Different molecules have different electron structures and therefore favor different crystal lattices, but usually there is some lattice which lowers overall interaction energy and frees up as much energy as possible for the rest of the world's uncertainty.