Luck goes into it, but not much.
Most submissions are simply not publishable: they're badly written, have no market, have not been polished, are littered with spelling mistakes and typos, they're plagiaristic, they're libellous, or they're just plain boring.
Most submissions are sent to the wrong publishers: there’s no point sending a novel to a text-book publisher, or a children’s story book to a list which specialises in cookery books.
Most submissions don't follow guidelines: they’re printed out using single line spacing, or printed on both sides of each page.
Perhaps 5% of submissions avoid the above categories, and will be read, and considered, by whoever it is they're sent to. Which narrows the odds considerably. After that, it's down to how good a writer you are, and whether or not your work is considered publishable in today's market. There is some luck involved, but far less than it seems from the outside.