You don't have to go all-in into coding. If you use Wordpress or some other platform to build your website (for yourself or others) you can ease into it by learning html/css to help with customizing and building your mind for problem-solving, and then move on to php and js for more complex tweaks. Learning through doing is very effective.I need to build my own website for my business within 2 -3 years. That's the long term goal, do you think it's viable to learn coding for that? I also might be moving to another country so it wouldn't hurt to learn a new skill for freelancing right?
So why 2-3 years?
You seem to have aligned goals and desires: learn coding + build your website, so just get started with both and figure it out along the way. Get yourself a domain and hosting if you haven't, jump on stack overflow and build your website. It's gonna suck at first, but that's fine. Good thing you don't have to do it for a client as your only source of income and with a strict deadline. The pressure you'll have is under your complete control, as is the progress you'll be making.
And to answer your initial question... web development is still viable. Businesses still need sales and clients, and websites are a great way to augment the sales process. The end result and the RoI is what matters most, moreso than what language you program the website in or whether you take shortcuts through WP. The opportunity cost for them to do it on their own is poor, so ofc they're going to hire an expert to do it for them.
Someone mentioned an SEO venture. Web development and SEO go hand in hand, if the purpose of your service is to help people create more value, and not just have a pretty business card through a virtual real estate property.
@Andy Black has a lot of good content on here about how you should do these things. Some are years old, but still very relevant today.
Good luck and don't waver
P.S.: You can build your own website in like 2 weeks with 0 experience or know-how. Don't be discouraged.