Everyone who's a permanent resident in Sweden gets a personal identity number, it's not tied to your citizenship. That would be illegal anyway, at least for citizens of other EU countries.
There's a lower-level, different number, which is less powerful, but easier to get.
> Everyone who's a permanent resident in Sweden gets a personal identity number, it's not tied to your citizenship
Same in Denmark too. You get a "CPR" number, and can login to most government services (as well as some commercial ones) with "MitID" (my ID). It's quite convenient. I can even use my MitID to buy alcohol without having to interact with another human being in Rema 1000 using their self-checkout app.
Ireland—where I moved from—has a similar "PPS" number that all residents can get, although the online aspect is not nearly as well integrated as it is here in Denmark; it's slowly improving.
What do non-citizens use in Sweden to get around?
The "everything apps" of places that have them aren't usually restricted to only citizens (though some admittedly have shitty UIs for non-citizens)