Are image addresses security relevant?

You’ve asked a good question… well, a couple of questions.

Considering the example at face value.

Larger sites have an image url like this. Why?

. <img src="https://wordpress.stackexchange.com/questions/315533/imgrur.com/9keqqq"/>

There are any number of reasons but let’s deal with the most obvious. “Imgur” is an example of a service that hosts “interesting” images and they encourage people to join and/or share those images. In the case you mention, the site (whether large or small) may want an image to emphasis something in a post; they don’t have a suitable image, or their own stock, and they don’t want to pay for a stock image (not in this example case at least), so instead they select an image from Imgur.

Is that a security thing? No.
Or to save space on the server? Possibly, but unlikely.

And how can i do that in PHP? I am currently using WordPress.

Easy. You don’t have to know any PHP. WordPress does it all for you. When you click “Add Media” in the “Edit Post” screen, WordPress takes you to this screen. There’s a menu option here that’s not often noticed – “Insert from Url”.
enter image description here
Click the menu option: insert an url, and then add caption, alt text, alignment, and ‘link to’ as usual. Then click the “Insert into post” button.
Here’s the code inserted into the post. Much the same as usual except for the url.
<insert image
Likewise, this is the html in the web page.
enter image description here

Considering the example in terms of website optimisation.

One possibility is a site (large or small) might be trying to optimise the performance of their website. The codex has a page on this: “WordPress Optimization“, and there are plenty of other resources on the net. One of the options is “Offloading”:

Using a CDN can greatly reduce the load on your website. Offloading
the searching and delivery of images, javascript, css and theme files
to a CDN is not only faster but takes great load off your WordPress
server’s own app stack. A CDN is most effective if used in conjunction
with a caching plugin.
“.

So says the codex; this is a simplistic statement and there is, as usual, much more to the issue than this. But this is enough to launch a reader onto the path of enlightenment 😉

This introduces the subject of a CDN (Content Delivery Network). Greater minds than mine have written on this, but for a quick, down-to-earth, no spin, primer “Adding and Leveraging a CDN on Your Website” at CSS-Tricks is as good a place as any to start.

Now your example and questions take on a different meaning, though funnily enough some the answers remain much the same.
Why do larger sites have a different url for, say, images? In order to improve the performance of their site. However, let me just add that Imgur is NOT a CDN and is NOT recommended as a substitute for a CDN.

Is that a security thing? No.
Or to save space on the server? Possibly, but not necessarily and unlikely.
And how can i do that in PHP? I am currently using WordPress. You add images in exactly the same way as described above.

Creating and using a CDN involves more than just signing up for a service but there are loads of step-by-step tutorials to be found – I Googled “tutorial using cdn with wordpress” (date ‘Past year’). Normal rules apply – some may be better than others, some may be biased, some may be accurate/inaccurate, etc. My point is that there is plenty of information to be had.