They don't know for certain. It's an inexact science. They do the best they can.
Alan Greenspan was known for pouring over all the economic data available for hours while mostly in the bathtub trying to make sense of what was happening in the economy. But ultimately, it came down to making an informed decision based on knowledge, reasoning, experience and intuition.
Policy objectives (which are quasi-political) can also come into play as sometimes desired results can compete. The classic example of this is economic growth vs. inflation.
Critics of government monopolized central banks argue that it is impossible for any single individual or group of policy makers to choose rates correctly and overnight interbank lending rates should be allowed to float freely and be determined by the market vis-a-vis supply-demand equilibrium. Hence the popularity of LIBOR and to a lessor extent EURIBOR as these are closer to market pricing than, say, the Fed Funds Rate. However, these are still only averages of central bank policy decision and, therefore, are not purely market-driven.