The degree to which is important us up for debate but to strong consensus in my circlesnis having appropriate keywords in the URL are significantly beneficial. Your first format is better from an SEO POV.
A common compromise is a format like https://www.example.com/12345/description-here can give you the best if both worlds by having an ID for the server (which ignores the end bit) and the keywords for the server.
The how depends on the web server and programming language and can't be easily answered. In the broadest terms you get the web server to push any requests through a single script which decodes the URL and pulls the appropriate content.