The t-test is the standard way to compare means when the population's spread is unknown, which is nearly always.
It asks whether a difference in means is large compared with the noise in the data.
The noise is measured by the standard error of the difference, worked out from the samples themselves.
A t statistic near 0 means the difference is small relative to the noise, and a large one means the opposite.
The t distribution is used instead of the normal because the spread was estimated from the sample, which adds uncertainty.
Its shape depends on the degrees of freedom, roughly the sample size, and it approaches the normal as samples grow.
A 1-sample t-test compares a mean with a fixed value, such as checking whether average delivery time is 30 minutes.
A 2-sample t-test compares 2 independent groups, such as customers shown 2 different versions of a page.
A paired t-test compares 2 measurements on the same units, such as each store's sales before and after a change.
Pairing removes the differences between units, so it often detects effects that an unpaired test would miss.
Welch's t-test does not assume the 2 groups have equal spread and is a safe default for comparing groups.
Strongly skewed data in small samples can break the test, and a test based on ranks may suit it better.
Large samples make the test robust to skew, because the sampling distribution of the mean becomes close to normal.
In practice, t-tests sit behind most comparisons of averages in reports and experiments.
The usual mistake is using a 2-sample test on paired data, which throws away the pairing and loses power.