I've been building personal websites since sometime in the mid 90s. Ever since I got access to the web, I didn't just want to consume it, I wanted to build it, or at least, build my little part of it. I've never stopped and thought about why, though. This site is never going to make me money. I'm not going to be able to make a living as a developer based on what I've learned from building it. So why bother?
In thinking about it, it comes down to a few factors: learning, agency and nostalgia.
First up, as a general rule, learning something new is always time well spent and the problem-solving aspects of the process are also pretty satisfying. There's a little endorphin rush that comes with getting something working after having gone down a few too many blind alleys, but being forced to think about a problem differently and come up with an alternative approach (or multiple alternative approaches as is often the case for me) is always going to be a worthwhile exercise; if nothing else, it makes you appreciate how difficult doing seemingly trivial things can be.
"The greatest teacher is called 'doing'." --Kevin Kelly, 99 Additional Bits of Unsolicited Advice
Related: the ability to experiment with different ways to tackle a problem is something which generates a significant amount of enjoyment for me; messing about with stuff, just to see what happens is actually kind of fun.
Then there's the agency element; in whatever small ways I can, I want to exert more control over the how the things I create are presented to the world and how they are used more broadly. I'm under no illusions about the value of my photos or my writing or my random thoughts, but I'm not OK with the idea that a giant tech company gets to use those things in perpetuity to build advertising profiles of me and my family and friends and make however many fractions of a cent whenever someone wants to see what I've been up to and then use those profiles to follow us around. I'm perfectly willing to trade off the ease and reach of social media (which are debatable in any case) against being able to do things the way I want and respecting the privacy of others. I realize that this is in all likelihood a small and (probably) ineffective action to take, but it's something I'm choosing to do anyway.
I'd be lying if I said that nostalgia didn't play a part as well. Setting aside discussions about the toxicity of the things being published, the web has become an increasingly sterile and boring place--it's just not as entertaining as it used to be. Part of it is due to the inevitable and increasing commercialization of the web, but the decline in the number of personal sites--the places where people used to dive deep into the things they were passionate about; the (often obscure) bands, pastimes, whatever--is a big contributing factor. The "quality" of those old-school sites varied wildly, but the proliferation of them and the joys of going down all those rabbit holes made messing about on the web fun. I don't think I've ever heard anyone ever say they had fun scrolling through their Facebook feed. But all that said, the existence of sites like The Forest does give me some comfort that it's not all social media silos and bland corporate brochureware.
For me, the flip side (or not--I haven't decided yet) is that I'm not a professional software developer, so there's almost always a certain feeling of tenuousness or fragility to the code I write. Sure, it works fine now, but what about the edge cases? I know enough to know that I can't have a handle on every possible error and my ability to troubleshoot and fix problems only goes so far. I've had to do the delete-it-all-and-start-from-scratch thing more than once after creating a situation for myself that I couldn't resolve. Basically, I just don't trust that the code I've written is entirely robust. But I can live with that.
In the end though, it's mostly about engaging my brain in a different way and keeping myself entertained. It's a combination of creative outlet and learning exercise and it gives me something to do when I have a little downtime, just like any other hobby... some people paint, some people bake, some people build miniature trains; I like to mess around with my website. For me, code serves the same purpose as tubes of paint or flour and eggs or sections of model railroad track--I start with the same building blocks as everyone else, but try to combine them in a slightly different way to make something that's uniquely mine.
"A hobby is something creative that’s just for you. You don’t try to make money or get famous off it, you just do it because it makes you happy." --Austin Kleon, Steal Like an Artist
So why? I guess it's because building all this is something I enjoy doing and, until it stops being fun, is something I'll keep doing.