Many security experts advise not to click on malicious URLs. How can clicking a URL affect a computer's security?
If a malicious file was downloaded and executed, then a computer's security may be breached, but how can just visiting a URL do this?
You can be infected via the use of what is called a drive-by-download exploit. This is how malware can download and install itself on your machine simply by loading a web page that contains it.
It works by finding vulnerabilities that allow it to escape whatever sandboxes it is supposed to be playing in, and execute arbitrary, malicious code on your machine.
It could be part of a Cross Site Reqest Forgery (CSRF) attack which isn't so much an attack on the users computer but an attack on their web application accounts. Say you have an account on CrappyBank.com's website and they are not protecting against CSRF attacks. If CrappyBank uses the following to transfer funds:
A malicious link could look like this:
And if you were logged in to your bank account at the time, you would inadvertently be transferring funds to the malicious users account.