"if then else" is indicative of an underlying pattern that exists at a more fundamental level. In that sense, it was "discovered", not invented.
Depending on the language, the syntax of "if then else" is not needed and is syntactic sugar.
In the Lambda Calculus you can implement "if else" using "first" and "second".
Here is something equivalent in JavaScript.
const trueFn = (first, second) => first
const falseFn = (first, second) => second
const ifFn = (boolFn, first, second) => boolFn(first, second)
ifFn(trueFn, 'yes', 'no') // returns 'yes'
ifFn(falseFn, 'yes', 'no') // returns 'no'