That's a basic principle of Christianity, and possibly State communism, but not socialism in general. It's role in modern political theory is not as principle of action but criterion of evaluation - part of a description, not a prescription. It's a basic attribute of a well-functioning economic and political setup. You would not want your setup to function any other way - right? Surely we can all agree that any setup which wastes ability and fails to provide basic needs isn't working very well. Notice, by the way, that it does not say "to each only according to his needs". It does not say "from each according to his abilities, or else" either. Neither coercion of effort or limitation of reward is described.