Failure in maintaining protein solubility in vivo impairs protein homeostasis and results in protein misfolding and aggregation, which are often associated with severe neurodegenerative and systemic disorders that include Alzheimer's and Parkinson's diseases and type II diabetes. In this work we formulate a model of the competition between folding and aggregation, and derive a condition on the solubility of proteins in terms of the stability of their folded states, their aggregation propensities and their degradation rates. From our model, the bistability between folding and aggregation emerges as an intrinsic aspect of protein homeostasis. The analysis of the conditions that determine such a bistability provides a rationalization of the recently observed relationship between the cellular abundance and the aggregation propensity of proteins. We then discuss how the solubility condition that we derive can help rationalise the correlation that has been reported between evolutionary rates and expression levels or proteins, as well as in vivo protein solubility and expression level measurements, and recently elucidated trends of proteome evolution.