Wow. What a good question and at the same time such a complicated one.
First, depending on what you are doing, best solutions will differ. For a blog, an informational site, a simple game, you don't need everything to be top notch. If you make it top notch, you will most likely be wasting your money because you will not be using the top notch components.
For other, more mission critical applications, you want your software to be secure and scalable. So many things go into security. It has to do with coding practices. Some practices are more prone to hacks than others. It has to do with a secure server architecture, having more than one points of failure, keeping your database separate from web server, closing off unnecessary ports, opening necessary ports only to necessary components. And lots of other things.
Scalability is broad as well. It has to do with the code, server architecture and database. So many things go into this.
This is a very broad discussion and I'd love to see what others have to say on this. But, if you really need an answer to this question for your current software, you will need to hire a technical expert to evaluate your project.