They both have different advantages and disadvantages.
Under gravel filters are placed under the substrate so they draw water through the gravel, which itself acts as a biological filter. They are comparatively cheap, easy to install, and require little maintenance. However, they also have some drawbacks, such as:
Firstly they can clog fairly easily which reduces water flow.
They can trap waste and debris under the gravel, which can cause ammonia and nitrite spikes.
They are generally not suitable for planted tanks, as they can disturb the roots and limit nutrient availability.
They are not effective at removing dissolved organic compounds, which can affect water quality and clarity.
External filters have the advantage of pumping water through various media types, such as mechanical, chemical, and biological filters. They are more efficient and more customizable than under gravel filters. However, they too have some drawbacks, such as:
They are more expensive and more complicated to set up and maintain.
They can leak or break and cause water damage outside of the aquarium creating electrical hazards.
They can create noise and vibration that can disturb the fish and the user.
So, I guess the answer to your question depends on your budget, preferences, and aquarium setup. Some people prefer under gravel filters for their simplicity and reliability, while others prefer external filters for their performance and flexibility. There is no definitive answer to which one is more effective, as both have their pros and cons. You can also use both types of filters in combination to achieve the best results.