First, note that it is necessary to have at least 3 colors to obtain such a coloring. Indeed, it is easily shown by induction on the number of lines that the configuration contains at least one triangle formed by the lines (this is true for $n=3$, and if we add a line, either it leaves the triangle intact or it separates it into a quadrilateral and a triangle).

Let us show that 3 colors suffice. As in many other exercises, we perform a rotation of the plane so that no line is vertical, we sort the intersection points by increasing abscissa $A_{1}, \ldots, A_{n}$ (where $n=\binom{2021}{2}$) and we color them in the same order. At each step, we can always color the point in question with a valid color since if it is the intersection point of $(d)$ and $\left(d^{\prime}\right)$, the only constraints on the color of the point are those given by the point to its left on $(d)$ and the one to its left on $\left(d^{\prime}\right)$, and in all cases we can choose a color that fits.
Consider 2021 lines in the plane, no two of which are parallel and no three of which are concurrent. Let E be the set of their intersection points. We want to assign a color to each point in E such that any two points on the same line, and whose connecting segment contains no other point of E, are of different colors.

How many colors are needed at a minimum to achieve such a coloring?