discovering Mean Value Theorem mean value theorem for single variable function is very easy and intuitive once you "see" the formula.
Actually, My question, slightly weird but helpful, is that How does someone come up with this formula in the first place?
Because, every time I refer a book or video for proof, I always see that we introduce a new function as the difference between given function and the equation of line passing through the endpoints of the interval.
How would someone even think of that function in the first place?
P.S This question does not hinder the proof but it always circulates the thought that "How someone would have think of that first?"
 A: If you look in the Wikipedia article, the MVT was developed as an extension of earlier work such as Rolle's Theorem. In fact, if you check the references for the history section you get this presentation that even without speaker notes shows a lot of the lead-up to both the statement and proof of the theorem.
On slide 10, Cavalieri's claim from 1635 is essentially the MVT in pre-calculus language:

If a curved line is situated in one plane and if a straight line meets it in either two points, two line segments, or in a line segment and a point, then we can draw another straight line parallel to the previous line which touches the part of the curve situated between the two mentioned meetings.

Most of what follows that is refining it (including formalising what it means when we're talking about algebraic functions rather than drawing curves on a piece of paper) and various attempts at formally proving it. As for "How do you think of the proof?", unfortunately we can't ask Cauchy how he came up with his particular method, but the correspondence between Peano and Jordan from slide 12 onwards gives a little insight into how these things tend to develop - someone tries something, usually based on previous work, and then a lot of time is spent fixing the problems with it.
Some of it is like lightning - lots of different paths branch out, but you don't actually see anything happen until one of those paths suddenly makes a connection. When you're studying the subject, you usually don't get shown the 100 failed attempts, only the successful one, so it feels like mathematicians just magically think of the perfect way to prove something, but that's very far from the truth.
