Yes it all happened by accident. Just the same as if a tornado hit a junk pile and out came a nice shiny new Boeing 747.
Actually this is an excellent analogy.
Self-organizing systems reduce entropy in complete violation of the laws of thermodynamics.
There is a good analogy in quantum mechanics. If you drop an object onto a table enough times quantum mechanics states clearly that one of those drops will result in the object dropping straight through the table.
Life appears to me to be the one that dropped through the table.
After billions of years and trillions upon trillions of random interactions between pre-organic compounds something snapped together into a... metabolism that converted carbohydrates or sunlight or powerfully corrosive compounds emitted by oceanic thermal vents into substances that support a sustained reaction which is what life is.
Given stable conditions for a few more billion years and trillions of generations somehow that metabolism evolved into sentient hominoid creatures and all the other creatures we coexist with or discover by archeological means. Unbelievable but mostly a testament to the power of large numbers.

