I think your teacher was trying to be helpful by giving you a simple rule like "don't use idioms in formal writing". But, think of your own native language. Can you write a formal essay using idioms?
I'm going to assume that you can, but it depends on the context. It's the same in English. Some idioms are so common that they are used routinely in any communication. Others are less common, or limited to a particular dialect, and so not appropriate in a formal essay as the meaning may not be obvious.
"More harm than good" is an example of an idiom so common that no one will take any special notice of its use -- as long as you use it correctly. For example:
Patients with life-threatening illnesses often choose to accept the risk that any therapy to cure their condition may do more harm than good. For example, chemotherapy drugs work on the principle that cancerous cells are more susceptible to certain poisons than normal cells, but nevertheless the inevitable damage to normal tissue may leave the body unable to fight off serious infectious disease.
I use the idiom here, but I also explain what is meant by "more harm than good".