You should not confuse two kinds of relations, technological relations and relations describing the behaviour of an economic agent.
The production function doesn't describe the decision of a firm to produce or not produce, and what amount of output.
The production function is a technological relation, describing the technological possibilities of producing $Y$ with certain factors of production, $K$ and $L$, in this case. It links output with production factors.
In the theory of the profit maximization, in microeconomics, the production function represents a constraint, depending on the available technology, on what a firm can produce.
The firm, in the theory of profit maximization, maximize its profit, with the constraint of a given technology.
That is, profit maximization describes the behaviour of the firm, how much output the firm chooses to produce, the available technology says what is feasible, it restricts the choices of the firm.
Profit has nothing to do with technology, profit isn’t a production factor. So, it makes no sense introducing it in the production function.
To decide how much produce in order to maximize profit you have to call a manager.
To change the technology, you have to call an engineer or buy new machines.