The LaTeX command typesets a file of text using the TeX program and the LaTeX Macro package for TeX. To be more specific, it processes an input file containing the text of a document with interspersed commands that describe how the text should be formatted. It produces two files as output, a Device Independent (DVI) file that contains commands that can be translated into commands for a variety of output devices, and a `transcript' or `log file' that contains summary information and diagnostic messages for any errors discovered in the input file.
For a description of what goes on inside TeX, you should consult The TeXbook by Donald E. Knuth, ISBN 0-201-13448-9, published jointly by the American Mathematical Society and Addison-Wesley Publishing Company.
For a description of LaTeX, you should consult "LaTeX: A Document Preparation System" by Leslie Lamport, ISBN 0-201-15790-X, published jointly by the American Mathematical Society and Addison-Wesley Publishing Company.