Some of Ruger's handguns are rightly considered some of the strongest. They are both quality cast, and also tend to use more overall material. This makes them heavy, but the extra material as well as being quality castings more than compensates for them being cast. Making some of them able to withstand more than many forged designs.
That said if quality is otherwise equal, alloys and heat treatment good, etc Then forged is better than cast.
You can have bad forged and good cast.
Cast material is almost never pure material when melted, other material is added to help the metal flow, fill the mold, etc This creates a product that is often slightly more porous. The crystalline structure is also more uniform, but that also makes it weaker than a crystalline structure with aligned patterns supporting each other as in forged metal.
Forging starts with the desired material and smashes the crystals together, resulting in the metal being slightly denser and with a crystalline structure that resists deformation better. However there is a limit, excessive forging can lead to brittleness. Certain steps in the heat treatment can all help the final product, relieving certain stresses while retaining and increasing the strength.
Both processes have additional considerations and can be done poorly or well. A good casting is less expensive to do than a good forging. So it is easier to find good quality high strength castings by companies that have invested in a lot of equipment and have good experience than to find companies that do good forgings.
Forging costs more. It takes more energy and effort to smash a piece of metal into the desired shape than to melt it into shape with a mold. This means you pay more for forged even when they are of lesser quality than some available cast products.
But comparing two of the best products, with everything done in the ways to lead to the highest quality, a forged product would be superior.
In today's market few do high quality forgings of firearm components because it is just not economical. In a time when people will shop elsewhere if you charge more than their competitor for a product that does the same thing and is of similar quality, it makes more sense to sell to a larger market by casting parts and having a more competitive price tag.
Since neither process effects the final fit and finish which are the most noticed traits, the consumer rarely will base their opinion of quality on such things as the alloy used, whether it was forged or cast, or the steps in the process used, anyways. So a manufacturer will take the less expensive method that still gives adequate strength, and focus more on fit and finish the extent of which itself costs money.
They still need to make profit while selling at a competitive price to those shopping for a similar class of firearms. The absolute perfectionist that focuses on traits the market does not even notice would typically find themselves unable to price competitively and not be in business long.