Early terrestrial chemistry can't have stayed random for too long though - given the goldilocks conditions of multiple energy sources (solar, geothermal), mechanical agitation (lunar tides) and abundant water facilitating mixing/migration of chemicals. Chemical complexity must gave progressed fairly quickly, especially in environments (e.g. thermal vents, seashores) where factors like these were more pronounced.
The precursors to instruction-based biochemical factories like modern cells would have started out with things as simple as catalysts that favored certain reactions, and gradually grew in complexity (maybe via multi-product catalysts?) to encode the production of more and more specific chemical products.
The story here would be one of ever-increasing chemical complexities and ever-increasingly complex cells/proto-cells. Chemical products, and cycles, that may have been infinitely unlikely to have been created under initial conditions of randomness would eventually become incorporated into the chemistry of the cell whose production was encoded for and inevitable. Complexity would have grown with simpler biochemicals being combined into more complex ones, simple/shorter cycles growing into longer ones, etc.