Bounded Rationality, Learning, and Optimal Contracts