Warhammer 40k has a rules system that changes every couple of years, so the timing is good to get in now when things are fairly stable. What I'd add on top of what others have already suggested about starter sets is that before you buy them, you should have a solid idea of which faction appeals to you, because otherwise you risk ending up with an army you don't like and just quitting altogether.
Watch some YouTube videos where they show the different factions in action - Space Marines, Orks, Necrons, Genestealer Cults and so on. Maybe spend an hour or so scrolling through the r/Warhammer40k subreddit or forums, read what players say about each faction. Then once you've decided, the starter set has everything you need to start learning the game without getting bogged down in complexity.
One more thing: ask around if you've got a Games Workshop store or a gaming club nearby. Often they have copies of the rules you can flip through before buying, and the people are willing to teach you. We spend less when we actually know what we're doing, right?