1. giving permission to take an action
by all means, go ahead
If someone makes a request and you respond by answering 'by all means', it is the equivalent of saying 'yes, certainly, of course'. As a response to a question, 'by all means' is an affirmative answer and is also used to grant permission or a way of saying 'in every way'. In this way, it is used as a polite phrase in social and professional contexts.
2. no matter what happens
avoid by all means
A 'means of doing something' is a way of doing it. If you ask someone what 'means' they're going to use to do something, you're asking which processes they are going to use or what resources they require. Saying 'by all means' indicates to the other person that all resources and possibilities are available to them: "By all means, stay away from that company" - use all the tools at your disposal not to have contact with the company. "By all means, we will ensure you can study at University" - we will do everything in our power to make this a possibility. This is a formal phrase used in professional and social contexts, although it is most likely found in the form 'by whatever means (necessary)'. Similar in meaning to 'do everything in my power', and 'help you in any way I can'.