A Ph.D. is necessary if you think you want to move into research in academia. Because a Ph.D. is about deep research, its not a good option if you are trying to learn new skills and stay within industry. A masters degree may be a better option in that case.
As for switching to law, make sure you really believe you will be passionate about moving to law and not just looking at it as a way out of software development. Talk to people in law about what you need to know if you could be passionate You may be able to stay in software development and have a much more rewarding career if you change industry you work in.
What kind of software developer are you? Most software developers are at one end of the following spectrum:
- Coders who like to code. They enjoy writing beautiful idiomatic code in a language which suites there sensibilities about expressiveness, safety, readability, etc. They like to solve algorithmic problems with code. They are mistrustful of libraries and tools unless they take the time to understand how they work. Often then find it more efficient to write their own code than take the time to trust a library or tool.
- Hackers who like to hack together things. The don’t like to get bogged down in writing a lot of code and would ranter put something together with libraries and tools. Getting something work is what matters. Hard algorithmic problems don’t hold their attention and they throw away the problem and look for an alternative solution.
Most of software development is somewhere in the middle. Most software developed are line-of-business applications and are mostly "shuffling strings from a database to UI and back again”. This is true even if you work in a not-for-profit or government. These roles don’t suite coders because they the software can typical be delivered with code which assemblies libraries and tools together with little challenging algorithmic work. These systems often have difficult problems but they are about of the complexity of understanding and maintaining code which has been modified by many different people to achieve different goals over time. These also don’t interest hackers because building an application shuffling strings around is not very exciting.
You need to ask your self, are you a coder or a hacker? Which ever answer you come up with you should look for industries which need people with you temperament. I suggest looking for an industry rather than looking at particular jobs because job descriptions and even interviews don’t give you a good sense of what opportunities there will be over multiple years.
If you are a coder look for industries where people have hard problems where code can help. Examples include:
- Image processing for scientific or medical research
- Finical technology such as automated trading
- Development of software platforms, e.g. build database management systems or message queues systems.
If you are a hacker then steer away form developing to software and into industries where people use code to help them do other jobs. Examples include:
- Financial anylitics
- Data Science roles supporting decision making in organizations
- Software tools development in a internet-of-things start-up.