User agent checks are standard practice in web design, and have been since the very beginning of the internet. Without them, you can't tell who is looking at your website, which is especially important these days with the vast number of different web browsers and versions of those browsers. It's also extremely important for security, bad actors may abuse agent strings, which can be used to detect malicious behavior.
Without user agent checking, you wouldn't be able to determine which version of your site you serve to the client. Desktop, mobile, HTML only or something else based on the client's browser. The Macintosh Repository uses user agent checking to determine if you're running on a real classic Macintosh (or an emulator), and will disable SSL and download limits if you are.
Agent checks were especially important in the IE era, because IE didn't conform to web standards and was so hideously broken that web developers had to maintain an entirely separate copy of the website JUST for IE users to avoid getting complaints about broken pages. I hated hosting websites back then, half of each page would contain huge blocks of exception code to work around broken IE problems. Thankfully it's not as much of an issue anymore, but different versions of the same modern browsers can still handle pages in unpredictable ways. There was a defcon presentation some years back