A ceiling fan that wobbles when you turn it on is very frustrating. Most people will simply buy a balancing kit and attempt to balance the fan with small weights. This works great, so long as the ceiling fan has a solid foundation. In this case the foundation is the point where the fan connects to the ceiling.
A loose junction box may be the culprit. If the box is not properly secured to the ceiling, you will never get the fan to be stable. Also, the box may be plastic and have too much flex in it to support the weight of a fan. If the junction box is metal, you may be able to drive a few screws into it to make it rigid. If that doesn’t work you can try a brace bar.
A brace bar will solve many problems, including a loose junction box. You will need to remove the old junction box first. If it is nailed in, it is easier to run a demolition blade between the box and the joist to cut it free…just make sure you clear the cable out of the way. Once the old box is out, you can slide the brace bar into the hole and run the cable through it.