Despite the absence of a membrane-enclosed nucleus, the bacterial DNA is typically condensed into a compact body - the nucleoid. This compaction influences the localization and dynamics of many cellular processes including transcription, translation, and cell division. Here, we develop a model that takes into account steric interactions among the components of the Escherichia coli transcriptional-translational machinery (TTM) and out-of-equilibrium effects of mRNA transcription, translation, and degradation, in order to explain many observed features of the nucleoid. We show that steric effects, due to the different molecular shapes of the TTM components, are sufficient to drive equilibrium phase separation of the DNA, explaining the formation and size of the nucleoid. In addition, we show that the observed positioning of the nucleoid at midcell is due to the out-of-equilibrium process of messenger RNA (mRNA) synthesis and degradation: mRNAs apply a pressure on both sides of the nucleoid, localizing it to midcell. We demonstrate that, as the cell grows, the production of these mRNAs is responsible for the nucleoid splitting into two lobes, and for their well-known positioning to 1/4 and 3/4 positions on the long cell axis. Finally, our model quantitatively accounts for the observed expansion of the nucleoid when the pool of cytoplasmic mRNAs is depleted. Overall, our study suggests that steric interactions and out-of-equilibrium effects of the TTM are key drivers of the internal spatial organization of bacterial cells.