As per title, what is the real advantage of using three tiered architecture, where the user interface in one layer, the second layer for application and third layer for database? I can understand that , for example if the user interface is compromised then hackers have another two layers to hack in order to get to the data. However on another point of view, wouldn't my applications be slower if my database is on another server? Also, does a three tier architecture always need to be protected by firewall in between each layer? Overall I think if one layer is compromised, it means it's compromised...no matter how well you protect your systems.
A three tier architecture does not necessarily mean that all the tiers are on different servers or even processes. It is more a thing that you abstract the parts of your application from each other that lets them interact only with clearly defined interfaces. In your case it means keeping the storage logic (database) separate from the business logic (application) and from display of the results (HTML, CSS, ...). This separation is mainly a logical separation that allows an easier physical separation should you need it. The separation can be done inside processes (i.e. different objects for the tiers), or even different systems.
The separation between these parts is not mainly done because of security but so that you can easier understand and manage the application. It makes it possible to make changes on one layer without many changes to the other layer, i.e. you could scale the database or even change the underlying database without much impact to the application layer. Or you could have different UI (web, mobile app...) ideally without changing the application layer and the database.
Of course this kind of separation can be helpful for security too. Clearly defined interfaces between the tiers make it easier to audit the application. You could also better detect and deter possible attacks if you actually know how the parts should interact with each other. In short the application can be made more robust with less effort, which helps to scale, it but also helps in security. And if the different tiers are actually separate processes (which is usually the case with at least web server and database) then you could put them into different security realms, i.e. different user accounts, different containers, VM or even different servers. This helps in keeping the system more robust and less attackable too.
Nowadays, the Model-View-Controller Pattern has become much more than it originally was intented to be:
Used for e.g. buttons in an application, the intent was to decouple the View from the Model and the Controller, making the button's design, behaviour and logic interchangeable, resulting in a more object-oriented, dynamic and modular design.
Today it has become much more than a best-practice design pattern for implementing things like buttons in an application.
Comming back to your question, i think the security benefit from using the MVC-pattern for designing application-layers is basically that you have a much clearer overall-design, making alot of potential security-related bugs impossible.
e.g. it's not possible to make the Controller do anything he wasn't made for by being able to manipulate the View, given the MVC is implemented correctly.