Honestly, I don't recommend it. It's a stressful lifestyle, you have to do a lot, and it's rare that you make more than just switching jobs. Seeking jobs, doing negotiations / signing contracts, and dealing with the kind of bosses that don't understand software well — are all really annoying. I've been a contractor for 5 years now, and I'm genuinely not sure what the good part of it is
Ok, so how to do it / get started. Imo you need a well known public project and speciality. Being the lead dev of a popular open source project is a good way. People will reach out to you for help integrating it, or making something similar, or adding features they need & will pay for. A specialty is something like being really good at WebRTC, financial regulations law, graphics drivers, crypto smart contracts, etc — with a proven record. You need a brand for yourself, and it needs to be way stronger than just a resume. You need to spend part of your time networking & job hunting, always
An important part is either getting paid very well, or taking ownership stake in the projects you build to roll the dice that way. Otherwise, you would be better off doing a job. Why? Because a contracting firm, which I had, isn't worth anything in a sale, aside from the talent it has. Compare this with something like a SAAS startup where the value is a multiple of revenue and user count. Having a flat value for just the employees isn't as valuable as a 10x multiplier on a steady business. It's volatile. I've heard construction contractors complain the same way, "I just take a salary to build a house someone else flips for double, I wish I owned my own house"
Honestly, software jobs are lucrative and easy. Contracting is stressful and complicated. The freedom isn't much different