Fiction is any work that tells a story that isn’t meant to recount true events in a factually accurate way. The science part of science fiction is less clear, but most people I believe are comfortable with a standard of “I know it when I see it.”But for a more workable definition, it’s easiest to do this by first folding in fantasy.
Science fiction and fantasy imagine worlds that vary from ours in was caused by some x-factor. An x-factor can be a new technology, it can be the existence of unicorns, it can be magic, it can be time travel, it can be a zombie virus. In sci-fi and fantasy, we see plots that couldn’t happen in our world that are driven by circumstances that are currently unavailable to us. How science fiction and fantasy differ is that in science fiction there is an expectation that whatever the x-factor is, it is explainable with the scientific laws similar to our own. Zombies are made by a virus that works similarly to viruses we understand, a warp drive could be possible based on ideas about folding space, 1984 is made possible by surveillance technologies, etc. Science fiction is frequently categorized as “hard” sci fi based on how “realistic” the scientific conceits it uses are. Fantasy on the other hand, leans on differences that don’t need to be explainable, and most often are not. We don’t need to know how exactly fire comes out of a magic wand, or how something as heavy as a horse can be self-propelled by wings. Because science fiction seems “possible” in a way that fantasy seems “impossible” some people, myself included, find that sci fi has a harder edge for making commentaries about us as human beings and society as a whole.
Obviously, one can blur these lines. A Kid in King Arthur’s court is fantasy involving time travel, and Primer is sci fi, but is The Merchant and the Alchemists’ Gate fantasy or sci? We don’t know how his gate works, but we’re told he’s an alchemist, which is kinda like a scientist, so is that sci-fi? Who knows. It’s a decent enough working definition though.
P.S. Midichlorians were an attempt to shift Star Wars from fantasy to sci-fi.