It is a well known fact that if aliens invaded, it would be our puny kill-one-person-then-reload-for-half-a-second-or-more-firearms against their super-cool-ultra-mega-thingy-laser-mumble-quantum-force-unobtanium-whatever-ray-guns.
It's not a fact. We have 1-kill/1-reload weapons because they're what we need on Earth right now, but when the aliens turn up, we upgrade to chainguns mounted on exosuits with supplementary rocket launchers.
When they fly in with their interstellar spaceships, we fight back with ours and destroy them before they get to Earth.
Asimov's Green Patches has humans flying to an alien planet with an alien life form capable of mind control; reading the pilot's mind about Earth, it sneaks onto the ship and disguises itself as a section of wire in the control board. By the time the ship returns to Earth, the alien is poised to invade ... 'If the stowaway manages to reach Earth, it will eventually convert all life there into a single organism with a unified consciousness — and green patches of fur instead of eyes', but the section of control board it chose is related to landing and when that engages the creature is electrocuted - the sneak invasion attempt happened without the aliens developing space travel and is countered because of our superior technology. (Thanks to Henning Makholm for the story identification I couldn't remember)
When the Vogon constructor fleet flew in we had no way to fight back at all - they didn't quite invade, but they did wipe us out, guns weren't involved, the power difference was too great.
When the Independence Day aliens flew in, there was gunfighting but we properly fought back with superior computer technology:
When the aliens invaded in the Midwich Cuckoos:- 'The Russian town was recently "accidentally" destroyed by the Soviet government, using an "atomic cannon" from a range of 50–60 miles.' - they got nuked.
When MorningLightMountain comes for the Commonwealth:- 'the small human resistance that exists on what remains of the Commonwealth worlds attacked by the Primes. Human resistance forces have found two ways to fight back: using the Prime weapons (primarily directed-energy weapons) against the invaders, and disrupting communication between the slave caste (motiles) and the commanding caste (immotiles) of the Primes. Meanwhile, the humans in the remaining Commonwealth pursue other plans: to develop a set of weapons and warships to defend against the next Prime invasion and force the conflict back into Prime space;' - humans aren't fighting with our weapons of the time, we're fighting with stolen weapons of theirs to keep them away while we build better weapons.
Andromeda Strain - "An accidental invasion by an extraterrestrial microbe that almost instantly clots human blood or causes insanity."
Day of the Triffids is a biological invasion where a) they have no tech weapons, guns work fine against them, and b) so do flamethrowers.
WorldWar appears to have aliens arriving with similar level of technology due to a mistake in information collection, and humans fighting back with equivalent guns and also nukes.
In summary, as other people have said, if you want to tell a story where the aliens invade Earth, they necessarily must have the technology to get here. Yet we don't want Earth invaded so if we possibly can, we will try to intercept in space far away to neutralize it before it gets here, so that puts an upper-bound on our technology level as well. Not only must they be able to get here, we must not be able to get usefully off the ground.
And if you want the invasion to look like humanoid soldiers which current day humans can fight against, the aliens must be similar to us - if they are invincible robot humanoids, no appreciable fight can happen and humans will lose. If the invasion is a spec of nanomatter which turns the Earth into grey goo, humans will lose. Yet if they are humanoid, they need portable, powerful weapons allowing a small attack force to take on a planet - so they must be more powerful weapons.
Another factor is if you want to make it a relatable war story, it's basically going to look like World War II. No easily relatable and exciting war story is about how NSA cryptographers analyze alien radio signals with a deep-learning neural network to find a padding-oracle attack on the encryption used to authenticate the soldier with the directed energy weapon and then asking the populace to download an Android app which reuses smartphone wifi radios to interfere with it and the alien guns stop working. How dull would that be?
And again, right now humans use 2017 level technology to fight - we don't nuke each other because Earth is too small and life is too fragile for nuke-levels of energy and radiation. We're not developing more powerful weapons, because we don't need them. So when the aliens arrive, we're unprepared for bigger and more powerful weapons. we're developing more precise weapons which move humans away from the battlefield instead - a future fighting force won't have phased plasma rifles in the 40W range, and wasteful suppression fire, they will have 1-shot/1-kill personal self-targetting sniper/cruise missile launchers. Probably with the humans far away.
But other stories do exist - where the invasion is sneaky rather than ships full of soldiers, where the humans have higher technology but it's not a technological invasion, where the humans fight back with more powerful weapons than guns, where the humans fight back in space first, and more. I suspect stories where aliens invade by nudging an asteroid to destroy the native Earth dinosaur species and seed alien biped species instead, exist as well.
You get the story you want to tell.
PS. when was the last time you read a gripping story about the termite mound that spent years gearing up for war and then an anteater tore the side off and ate 20,000 of them and all their preparations for war were useless?
- The humans are going to win, fact.
- Both sides need to be roughly evenly matched or the stronger side will easily win and there's no story.
- Rooting for the underdog is more fun, stories are better with tension and imminent disaster, so the humans need to be the weaker side, therefore the aliens get to be stronger.