Why is the metric tensor of a expanding universe a function of time? Why is it not a function of distance between the galaxies? I heard this from a lecture. Can anyone help me understand?
The metric tensor is used to calculate distances. Since the distances between the galaxies change with time when nothing else changes, the metric tensor must be a function of time.
The reason is known as the cosmological principle:
The Earth doesn't occupy a privileged place in the Universe – an assumption going back to heliocentrists and Giordano Bruno in particular. At long distances, one may consider the Universe to be spatially uniform. Each place of the Universe is as good as any other. Effectively, this means that all the defining things such as curvature are independent of spatial coordinates and the metric tensor etc. may be written in such a way that the dependence on the spatial coordinates is either non-existent or trivial and universal (metric for the sphere or hyperboloid) while the only adjustable dependence is the dependence on time.
So all the quantities including the total curvature and the detailed components of the metric tensor may still depend and they do depend on time because the Universe does change as it's getting older. There is a qualitative difference between the Universe we see now and the Universe when it was young and hot. Note that there is some breaking of the (special relativistic) symmetry between space and time. The Universe is independent of space but it does depend on time. But that's how things are. Cosmic inflation partially explains the immensely accurate uniformity – and flatness – of the space we observe today by explaining the vast expanses of the Cosmos as an exponentially inflated seed of space which used to be small and therefore uniform.
But there's nothing that would make the young Universe independent of time. Things that don't depend on time must be in equilibrium, kind of, and a young Universe is as violent and as far from an equilibrium as you can get. As the Universe will get even older and emptier and cooler, it will effectively become independent on time as well – it will asymptotically become an empty de Sitter space (totally dominated by the positive cosmological constant i.e. dark energy).