The transformation between inertial Cartesian coordinates in Minkowski spacetime is affine. It becomes linear when the coordinate origins coincide. The qualification “inertial Cartesian” matters: accelerated or curvilinear coordinates can have nonlinear transformations even in flat spacetime.
This note revises my original Chinese answer.
A geometric argument
Use coordinates and in which the metric is the same constant Minkowski matrix . In both systems, the Levi-Civita connection coefficients vanish. The connection transformation law then implies
On a connected coordinate domain, all first derivatives are constant, so the inverse coordinate map is affine. Its inverse therefore has the form
with constant invertible and constant translation . Preserving the metric gives
Consequently is a Lorentz matrix. When both coordinate systems assign zero to the same event, , yielding a linear Lorentz transformation. The general affine transformation is called a Poincaré transformation.
What this assumes
The argument starts from Minkowski geometry and inertial coordinates. It is not a derivation of special relativity from pure mathematics: that geometry encodes physical assumptions about spacetime, supported by experiment. Another familiar route assumes spacetime homogeneity to obtain an affine transformation, then imposes the relativistic interval and a common origin.
Metric preservation is also not sufficient to establish the relativity principle for every imaginable law. A physical theory must have dynamics compatible with the transformations. The geometric condition identifies the transformations; covariance of the equations establishes the corresponding symmetry of that theory.
For the distinction between flat-space inertial coordinates and local frames in curved spacetime, see Lorentz transformations and general relativity and Tong's account of Lorentzian geometry.