I write mostly Science Fiction and Fantasy, and more science fiction than fantasy. So why these genres in particular?
I started as an inveterate reader of SF. That all got its start back when I was first reading. In first Grade the reading material was boring. Boring. Boring. Boring. One half of the class was reading about this stupid "Dick" and his stupid sister "Jane" (my mother had taught me to read at home and I was reading the Childcraft encyclopedias for entertainment). The other half of the room was reading an equally insipid book about "Tom".
Sometime about this time I was introduced to a picture book about a trip to the moon that appeared to be based on von Braun's old Colliers series. (The book was "You will go to the Moon" by Mae and Ira Freman.) That got me started. About the same time I remember watching coverage of several Apollo missions on TV.
A couple years later we moved and I changed schools and in the classroom library had a bunch of the "Tom Swift, Jr." books. This was the first Science Fiction I read that I knew as Science Fiction. The next year I got introduced to others, including Heinlein.
All of this stuff ignited in me a burning desire to go into space. I wanted to go into orbit, walk on the moon, see the moons of Mars pass overhead from the Martian deserts. And the way to get there was to become an astronaut. But in Fifth grade I started noticing a difficulty seeing the chalkboards at school. This got worse and worse until in 7th grade I finally got glasses. Given the standards of the time, where only military (or ex military) test pilots could become astronauts and that to be a military pilot (let alone a test pilot) one had to have perfect vision, that put paid to that idea.
And so Science Fiction filled the hole of the dream that could never come true. I could never go, but I could at least read about it. From that point on SF totally dominated my reading. Some years later I started branching out a bit and developing more "rounded" tastes but it remains SF that I come back to when I read for fun.
So when I started writing, I started writing SF since that's just the way my mind worked by that point.
My introduction to fantasy was a bit different. A friend of mine handed me a book and said "Here, read this." He was so serious about it that I didn't dare refuse. The book was "The Hobbit". Soon, I had read The Lord of the Rings and The Silmarillion. And, a few years later, I came across a book marketed as "for people who have finished The Lord of the Rings and are looking for something else to read." Yes, "The Sword of Shanarra" was really marketed that way. And while Mr. Brooks seems to get a lot of hate in certain segments of fantasy fandom, he's probably laughing about that all the way to the bank as he turns out best seller after best seller after best seller. In any case, Mr. Brooks' books showed me that there was more Fantasy out there and so I added that to my reading.
One of the things I liked about both SF and the Fantasy I was reading is that the characters generally mattered. What they did had an influence on the world far beyond what a high school student from a poor family like me could ever realistically hope to. This was much what drew me to superhero comics and some of the other things I was reading. This was so different from the "literature" I was being assigned as reading in school that it was a whole other world. (I have, of course, since learned that it's quite possible to write about people who matter, who make a difference, without going into fantasy and SF, but by that time my tastes had largely settled).
By this point, even when I have a story idea that could be told without science fiction or fantasy themes I tend to write it that way simply because that's the way the stories come out. I enjoy Shakespeare (The Tempest is my favorite). I've read London and appreciated it. I've found the mysteries of Lawrence Block entertaining. But I keep coming back to Science Fiction and Fantasy.
In romance, first loves are often ephemeral, but in this case the first love has been the deepest and the most lasting.
So it's not really a case of "why write science fiction and fantasy?" but rather "why write anything else?"