Appears random, but isn't. Forgoing hunter-gathering and taking on farming, and other such pivotal events, may indeed be random in their exact happening, but they were forced by there being species of humans for millions of years (yes, I am counting homo erectus, etc.) having billions of chances to do that, and by the inevitable evolution pressure put on all our closest hominids by the changing world, and the different conditions they faced as they spread out throughout the world.
And farming isn't the best example of a singular pivotal event, as
we independently invented farming at least a dozen times. I was actually surprised that it happened this many times, as I searched for this only aware of
the independent discovery of farming of the Amazon region, and in
America in general.
I don't know for sure that it only first happened tens of millions of years ago like you say, but even if it did, it was precipitated by humans spreading around the world and increasing in numbers, thereby eventually making it happen again and again and again.
However, a lot of the required factors in the long haul may be randomly present so as to make us pretty unlikely. JirinPanthosa pointed to one – extinction events. We've all heard how Jupiter's position in the solar system may be critical, according to the vacuum cleaner speculation, too. Then there's the coincidence of hands and brains – I wouldn't be surprised if dolphins are almost as smart as us, or even smarter, but a dolphin civilisation would be impossible; probably a bad example, because those aren't independent evolutionary, so it is explained by evolution. But
barely not going extinct back when we were endangered species isn't. Nor is running out of time before the planet is cooked by the sun.
If we had been killed off, leaving the dolphins as the smartest things on the planet, they are unlikely to have built ever cities, and even if they evolved into something better adapted to building things, it wouldn't have happened before plant and animal life is killed off by the heating sun in a few hundred million years.