Several answers to this question come to my mind, some of which are already covered by the comments. Actually, if I'd ever were to write a textbook I'd do the same.
Since you cite Rudin I'd like to note in advance that many consider his books on analysis among the best, and I don't think it is a coincidence that someone writing books which do get that attention and appreciation follows this practice.
Something everyone learning mathematics (not only there) has to learn is the reality (from which you are well protected at school) that you will usually (not sometimes, usually) face problems which you cannot solve. Maybe not at all, at least not with the first attempts or with little effort. You have to find your way to the solution one way or the other, either by thinking harder and smarter, by talking to people, whatever. But you don't get it for free, in real life. Almost never. It is an experience of people who teach (not just math), that this fact has to be taught as well, unless they want to produce many many people leaving university who will then have to learn it too late the hard way.
And, no insult intended, one word of advice: if you find you really need the solutions to make your way through such books, you may want to consider whether you've really chosen the right topic for you.
And one additional remark: why do you need the solution? By working seriously on a problem you may learn more -- even if you cannot solve it -- than by looking up the answer (and, very likely, missing most of the subtleties).