Molecular dynamics is a statistical mechanics method . Like Monte Carlo, it is a way to obtain a set of configurations distributed according to some statistical distribution function, or statistical ensemble. According to statistical physics, physical quantities are represented by averages over configurations distributed according to a certain statistical ensemble. A trajectory obtained by molecular dynamics provides such a set of configurations. Therefore, a measurements of a physical quantity by simulation is simply obtained as an arithmetic average of the various instantaneous values assumed by that quantity during the MD run.
Statistical physics is the link between the microscopic behavior and thermodynamics.
In the limit of very long simulation times, one could expect the phase space to be fully sampled, and in that limit this averaging process would yield the thermodynamic properties. In this way, MD simulations can be used to measure thermodynamic properties and therefore evaluate, say, the phase diagram of a specific material.