Which is the costliest step while designing BJT which makes it costlier against designing MOS?
Compare BJT with MOS in this postion:


BJT: Fig. 1-10
MOS: Fig. 1-18


It should be clear now that MOS transistors require less production steps (hence lower cost) and allow higher density. Those are the reasons while MOS won with BJT. However, MOS transistors are surface devices. That's why they appeared later compare to BJT which active area is located deep in the bulk.