You can use the following expression to eliminate all vertices from a line that deviate for a maximum distance from the direct line connecting the start- and end-point of a line. Use Geoemtry Generator or Geometry by expression (see here for details).
The expression evaluates for each vertex of the initial line, except for start- and end-point, if a buffer of distance
50 on line 20, change this value to fit your needs) intersects the direct line connecting start- and end-point.
If so, the output is an empty element, otherwise the output is the respective vertex as a point geometry.
So for each vertex, these outputs are collected in an array and then the array is filtered to retain only elements > 0. You get an array than only contains points.
These ponints represent the vertices further away from the line connecting start- and end-point than the distance you defined.
Add start- and end-point of the initial line at the beginning and end of the array and convert the array to a line and here you are!
generate_series (2, num_points( $geometry)-1),
1 -- change this distance
) = 0
then point_n ($geometry, @element)
Black line with initial vertices (red dots) as well as the vertices of the line created by the expression above in blue (adding a
nodes_to_points() function to the expression) - as you can see, just 2 vertices (start- and end-point) remain: