Are you sure that wasn't a movie?
I've never heard of the theory that humans and dinosaurs coexisted, at least not with credible evidence. It's probably something the creationists propagated.
Evolution is partly by chance. But evolution takes millions of years. So basically, what are the chances of something like humans eventually coming along? Well apparently after millions and millions of years and countless iterations of random morphs the chances are good.
It's like a startup, except without smart founders behind it. That's why it takes so long and so many iterations before evolution gets it "right." With a startup if you get something wrong you change it because the previous method failed (if you don't change it the startup fails). In evolution the species that doesn't get it "right" fails. The iteration of the species that does get it right obviously continues to thrive. So over millions of years there are constantly new iterations and the best ones make it through to now.
If this is new to you, it shouldn't be. Where are you from? As far as I know all schools in the US should get you up to speed with evolution. But judging from your writing you're probably not from an english speaking country?