Contact your local electrical provider and arrange a day for them to turn off the building's power at the street.
Confirm the power is off by checking whether or not any device in the home has power. Double check that there is no electricity by touching a non-contact electrical detector to the supply wire's insulation.
Remove the screws that secure the cover on the main breaker. Remove the cover and set aside.
Inspect the loose connection for signs of melting wires or a burnt terminal. If either of these conditions exist, you need to replace the entire main breaker.
Tighten the connection on the main breaker by turning the terminal screw clockwise. Reinstall the panel cover by reversing the process used to remove it.